diff options
Diffstat (limited to 'lib/utils/read-json.js')
-rw-r--r-- | lib/utils/read-json.js | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/lib/utils/read-json.js b/lib/utils/read-json.js index d1bba10f5..68153ab21 100644 --- a/lib/utils/read-json.js +++ b/lib/utils/read-json.js @@ -8,7 +8,7 @@ readJson.clearCache = clearCache var fs = require("graceful-fs") , semver = require("semver") , path = require("path") - , log = require("./log.js") + , log = require("npmlog") , npm = require("../npm.js") , cache = {} , timers = {} @@ -17,7 +17,7 @@ var fs = require("graceful-fs") function readJson (jsonFile, opts, cb) { if (typeof cb !== "function") cb = opts, opts = {} if (cache.hasOwnProperty(jsonFile)) { - log.verbose(jsonFile, "from cache") + log.verbose("json from cache", jsonFile) return cb(null, cache[jsonFile]) } opts.file = jsonFile @@ -180,8 +180,7 @@ function processJsonString (opts, cb) { return function (er, jsonString) { if (opts.file && opts.file.indexOf(npm.dir) === 0) { try { json = require("vm").runInNewContext("(\n"+jsonString+"\n)") - log.error(opts.file, "Error parsing json") - log.error(ex, "parse error ") + log.error("Error parsing json", opts.file, ex) } catch (ex2) { return jsonParseFail(ex, opts.file, cb) } @@ -209,7 +208,7 @@ function typoWarn (json) { typoWarned[json._id] = true if (json.modules) { - log.warn("package.json: 'modules' object is deprecated", json._id) + log.verbose("package.json", "'modules' object is deprecated", json._id) delete json.modules } @@ -235,8 +234,8 @@ function typoWarn (json) { Object.keys(typos).forEach(function (d) { if (json.hasOwnProperty(d)) { - log.warn( "package.json: '" + d + "' should probably be '" - + typos[d] + "'", json._id) + log.warn( json._id, "package.json: '" + d + "' should probably be '" + + typos[d] + "'" ) } }) @@ -259,8 +258,9 @@ function typoWarn (json) { var scriptTypos = { "server": "start" } if (json.scripts) Object.keys(scriptTypos).forEach(function (d) { if (json.scripts.hasOwnProperty(d)) { - log.warn( "package.json: scripts['" + d + "'] should probably be " - + "scripts['" + scriptTypos[d] + "']", json._id) + log.warn( json._id + , "package.json: scripts['" + d + "'] should probably be " + + "scripts['" + scriptTypos[d] + "']" ) } }) } @@ -268,7 +268,6 @@ function typoWarn (json) { function processObject (opts, cb) { return function (er, json) { // json._npmJsonOpts = opts - // log.warn(json, "processing json") if (npm.config.get("username")) { json._npmUser = { name: npm.config.get("username") , email: npm.config.get("email") } @@ -310,7 +309,7 @@ function processObject (opts, cb) { return function (er, json) { // uncomment once this is no longer an issue. // if (cb) return cb(e) // throw e - log.error(msg, "incorrect json: "+json.name) + log.error("json", "incorrect json: "+json.name, msg) json.repostory = json.repositories[0] delete json.repositories } @@ -335,14 +334,14 @@ function processObject (opts, cb) { return function (er, json) { } if (repo.match(/github\.com\/[^\/]+\/[^\/]+\/?$/) && repo.match(/\.git\.git$/)) { - log.warn(repo, "Probably broken git url") + log.warn(json._id, "Probably broken git url", repo) } json.repository.url = repo } var files = json.files if (files && !Array.isArray(files)) { - log.warn(files, "Invalid 'files' member. See 'npm help json'") + log.warn(json._id, "Invalid 'files' member. See 'npm help json'", files) delete json.files } @@ -361,7 +360,7 @@ function processObject (opts, cb) { return function (er, json) { // if it has a bindings.gyp, then build with node-gyp if (opts.gypfile && !json.prebuilt) { - log.verbose([json.prebuilt, opts], "has bindings.gyp") + log.verbose(json._id, "has bindings.gyp", [json.prebuilt, opts]) if (!scripts.install && !scripts.preinstall) { scripts.install = "node-gyp rebuild" json.scripts = scripts @@ -370,7 +369,7 @@ function processObject (opts, cb) { return function (er, json) { // if it has a wscript, then build it. if (opts.wscript && !json.prebuilt) { - log.verbose([json.prebuilt, opts], "has wscript") + log.verbose(json._id, "has wscript", [json.prebuilt, opts]) if (!scripts.install && !scripts.preinstall) { // don't fail if it was unexpected, just try. scripts.preinstall = "node-waf clean || (exit 0); node-waf configure build" @@ -460,7 +459,7 @@ function processObject (opts, cb) { return function (er, json) { json._npmVersion = npm.version json._nodeVersion = process.version if (opts.file) { - log.verbose(opts.file, "caching") + log.verbose("caching json", opts.file) cache[opts.file] = json // arbitrary var keys = Object.keys(cache) @@ -522,8 +521,9 @@ function testEngine (json) { } if (json.engines.node === "") json.engines.node = "*" if (json.engines.node && null === semver.validRange(json.engines.node)) { - log.warn( json.engines.node - , "Invalid range in engines.node. Please see `npm help json`" ) + log.warn( json._id + , "Invalid range in engines.node. Please see `npm help json`" + , json.engines.node ) } if (nodeVer) { |