diff options
-rwxr-xr-x | bin/npm-cli.js | 1 | ||||
-rw-r--r-- | lib/access.js | 1 | ||||
-rw-r--r-- | lib/npm.js | 2 | ||||
-rw-r--r-- | lib/utils/error-handler.js | 6 | ||||
-rw-r--r-- | lib/utils/lifecycle.js | 56 |
5 files changed, 35 insertions, 31 deletions
diff --git a/bin/npm-cli.js b/bin/npm-cli.js index 2346feba4..55fa054d6 100755 --- a/bin/npm-cli.js +++ b/bin/npm-cli.js @@ -1,6 +1,5 @@ #!/usr/bin/env node ;(function () { // wrapper in case we're in module_context mode - // windows: running "npm blah" in this folder will invoke WSH, not node. /*global WScript*/ if (typeof WScript !== 'undefined') { diff --git a/lib/access.js b/lib/access.js index 158ce5054..69527c2aa 100644 --- a/lib/access.js +++ b/lib/access.js @@ -35,7 +35,6 @@ access.completion = function (opts, cb) { } else { return cb(null, []) } - break case 'public': case 'restricted': case 'ls-packages': diff --git a/lib/npm.js b/lib/npm.js index 4d4516506..c0c9f6a0f 100644 --- a/lib/npm.js +++ b/lib/npm.js @@ -87,7 +87,7 @@ npm.command = c if (commandCache[a]) return commandCache[a] - var cmd = require(__dirname + '/' + a + '.js') + var cmd = require(path.join(__dirname, a + '.js')) commandCache[a] = function () { var args = Array.prototype.slice.call(arguments, 0) diff --git a/lib/utils/error-handler.js b/lib/utils/error-handler.js index 91b180e1b..6eac7e957 100644 --- a/lib/utils/error-handler.js +++ b/lib/utils/error-handler.js @@ -78,9 +78,11 @@ function exit (code, noLog) { } }) rollbacks.length = 0 + } else if (code && !noLog) { + writeLogFile(reallyExit) + } else { + rm('npm-debug.log', reallyExit) } - else if (code && !noLog) writeLogFile(reallyExit) - else rm('npm-debug.log', reallyExit) function reallyExit (er) { if (er && !code) code = typeof er.errno === 'number' ? er.errno : 1 diff --git a/lib/utils/lifecycle.js b/lib/utils/lifecycle.js index b5893ff6a..fd1a59b74 100644 --- a/lib/utils/lifecycle.js +++ b/lib/utils/lifecycle.js @@ -293,8 +293,10 @@ function makeEnv (data, prefix, env) { prefix = prefix || 'npm_package_' if (!env) { env = {} - for (var i in process.env) if (!i.match(/^npm_/)) { - env[i] = process.env[i] + for (var i in process.env) { + if (!i.match(/^npm_/)) { + env[i] = process.env[i] + } } // npat asks for tap output @@ -311,31 +313,33 @@ function makeEnv (data, prefix, env) { ) } - for (i in data) if (i.charAt(0) !== '_') { - var envKey = (prefix + i).replace(/[^a-zA-Z0-9_]/g, '_') - if (i === 'readme') { - continue - } - if (data[i] && typeof data[i] === 'object') { - try { - // quick and dirty detection for cyclical structures - JSON.stringify(data[i]) - makeEnv(data[i], envKey + '_', env) - } catch (ex) { - // usually these are package objects. - // just get the path and basic details. - var d = data[i] - makeEnv( - { name: d.name, version: d.version, path: d.path }, - envKey + '_', - env - ) + for (i in data) { + if (i.charAt(0) !== '_') { + var envKey = (prefix + i).replace(/[^a-zA-Z0-9_]/g, '_') + if (i === 'readme') { + continue + } + if (data[i] && typeof data[i] === 'object') { + try { + // quick and dirty detection for cyclical structures + JSON.stringify(data[i]) + makeEnv(data[i], envKey + '_', env) + } catch (ex) { + // usually these are package objects. + // just get the path and basic details. + var d = data[i] + makeEnv( + { name: d.name, version: d.version, path: d.path }, + envKey + '_', + env + ) + } + } else { + env[envKey] = String(data[i]) + env[envKey] = env[envKey].indexOf('\n') !== -1 + ? JSON.stringify(env[envKey]) + : env[envKey] } - } else { - env[envKey] = String(data[i]) - env[envKey] = env[envKey].indexOf('\n') !== -1 - ? JSON.stringify(env[envKey]) - : env[envKey] } } |