diff --git a/bin/npm-cli.js b/bin/npm-cli.js index 2346feba47d60..55fa054d66601 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 158ce50544f1c..69527c2aa4b34 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 4d45165063541..c0c9f6a0f7edc 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 91b180e1b305a..6eac7e9577f4f 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 b5893ff6a43f0..fd1a59b74c75b 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] } }