Merge pull request #9021 from meteor/abernix/fix-windows-npm-1.6

Changes to npm installation methods for npm@5 / Meteor 1.6.
This commit is contained in:
Ben Newman
2017-08-16 11:38:55 -04:00
committed by GitHub
2 changed files with 15 additions and 9 deletions

View File

@@ -86,13 +86,6 @@ exports.getEnv = function (options) {
env.NPM_CONFIG_PREFIX = devBundleDir;
}
// Make sure we don't try to use the global ~/.npm cache accidentally.
if (! env.NPM_CONFIG_CACHE) {
env.NPM_CONFIG_CACHE = path.join(
// If the user set NPM_CONFIG_PREFIX, respect that.
env.NPM_CONFIG_PREFIX, ".npm");
}
if (env.METEOR_ALLOW_SUPERUSER) {
// Note that env.METEOR_ALLOW_SUPERUSER could be "0" or "false", which
// should propagate falsy semantics to NPM_CONFIG_UNSAFE_PERM.

View File

@@ -830,9 +830,22 @@ Profile("meteorNpm.runNpmCommand", function (args, cwd) {
isWindows ? "npm.cmd" : "npm"
));
// On Windows, `.cmd` and `.bat` files must be launched in a shell per:
// http://nodejs.org/api/child_process.html#child_process_spawning_bat_and_cmd_files_on_windows
//
// Additionally, the COMSPEC environment variable is meant to have the path to
// cmd.exe, but we'll use 'cmd.exe' if it's not set, in the same spirit as
// http://nodejs.org/api/child_process.html#child_process_shell_requirements.
let commandToRun = npmPath;
if (isWindows) {
args = ['/c', npmPath, ...args];
commandToRun = process.env.ComSpec || "cmd.exe";
}
if (meteorNpm._printNpmCalls) {
// only used by test-bundler.js
process.stdout.write('cd ' + cwd + ' && ' + npmPath + ' ' +
process.stdout.write('cd ' + cwd + ' && ' + commandToRun + ' ' +
args.join(' ') + ' ...\n');
}
@@ -853,7 +866,7 @@ Profile("meteorNpm.runNpmCommand", function (args, cwd) {
return new Promise(function (resolve) {
require('child_process').execFile(
npmPath, args, opts, function (err, stdout, stderr) {
commandToRun, args, opts, function (err, stdout, stderr) {
if (meteorNpm._printNpmCalls) {
process.stdout.write(err ? 'failed\n' : 'done\n');
}