From aa620a8b5cdcba86046ac7474266fdd341021993 Mon Sep 17 00:00:00 2001 From: isaacs Date: Thu, 12 Jun 2014 14:51:45 -0700 Subject: Properly handle errors that can occur in the config-loading process --- lib/npm.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib/npm.js') 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") -- cgit v1.2.3