diff options
author | isaacs <i@izs.me> | 2014-06-13 01:51:45 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2014-06-13 01:51:45 +0400 |
commit | aa620a8b5cdcba86046ac7474266fdd341021993 (patch) | |
tree | 66647e92937960a7d5f208509a6121520e03fc59 /lib/npm.js | |
parent | 1ab43c9efa49ff40a2313958f4fdcee6459cd90e (diff) |
Properly handle errors that can occur in the config-loading process
Diffstat (limited to 'lib/npm.js')
-rw-r--r-- | lib/npm.js | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/npm.js b/lib/npm.js index f2319bfd5..344e4d348 100644 --- a/lib/npm.js +++ b/lib/npm.js @@ -275,6 +275,8 @@ npm.load = function (cli, cb_) { function cb (er) { if (loadErr) return + loadErr = er + if (er) return cb_(er) if (npm.config.get("force")) { log.warn("using --force", "I sure hope you know what you are doing.") } @@ -307,6 +309,9 @@ function load (npm, cli, cb) { npmconf.load(cli, builtin, function (er, config) { if (er === config) er = null + npm.config = config + if (er) return cb(er) + // Include npm-version and node-version in user-agent var ua = config.get("user-agent") || "" ua = ua.replace(/\{node-version\}/gi, process.version) @@ -315,8 +320,6 @@ function load (npm, cli, cb) { ua = ua.replace(/\{arch\}/gi, process.arch) config.set("user-agent", ua) - npm.config = config - var color = config.get("color") log.level = config.get("loglevel") |