We no longer need to pass --force to npm install

(Also, make a test assertion useful: assert.equal's default truncation
is horrible.)
This commit is contained in:
David Glasser
2014-04-30 11:45:30 -07:00
parent 94074c0dcd
commit 314c8a1a34
3 changed files with 15 additions and 12 deletions

View File

@@ -1,5 +1,8 @@
## v.NEXT ## v.NEXT
* Speed up updates of NPM modules by patching NPM to work around
https://github.com/npm/npm/issues/3265 instead of passing `--force`.
## v0.8.1 ## v0.8.1
#### Meteor Accounts #### Meteor Accounts

View File

@@ -459,17 +459,18 @@ var installNpmModule = function (name, version, dir) {
// how to silence all output (specifically the installed tree which // how to silence all output (specifically the installed tree which
// is printed out with `console.log`) // is printed out with `console.log`)
// //
// We use --force, because the NPM cache is broken! See // We used to use --force here, because the NPM cache is broken! See
// https://github.com/isaacs/npm/issues/3265 Basically, switching // https://github.com/npm/npm/issues/3265 Basically, switching
// back and forth between a tarball fork of version X and the real // back and forth between a tarball fork of version X and the real
// version X can confuse NPM. But the main reason to use tarball // version X could confuse NPM. But the main reason to use tarball
// URLs is to get a fork of the latest version with some fix, so // URLs is to get a fork of the latest version with some fix, so
// it's easy to trigger this! So instead, always use --force. (Even // it was easy to trigger this!
// with --force, we still WRITE to the cache, so we can corrupt the //
// cache for other invocations of npm... ah well.) // We now use a forked version of npm with our PR
// https://github.com/npm/npm/pull/5137 to work around this.
var result = var result =
meteorNpm._execFileSync(path.join(files.getDevBundle(), "bin", "npm"), meteorNpm._execFileSync(path.join(files.getDevBundle(), "bin", "npm"),
["install", "--force", installArg], ["install", installArg],
{cwd: dir}); {cwd: dir});
if (! result.success) { if (! result.success) {
@@ -498,11 +499,10 @@ var installFromShrinkwrap = function (dir) {
ensureConnected(); ensureConnected();
// `npm install`, which reads npm-shrinkwrap.json. See above for why // `npm install`, which reads npm-shrinkwrap.json.
// --force.
var result = var result =
meteorNpm._execFileSync(path.join(files.getDevBundle(), "bin", "npm"), meteorNpm._execFileSync(path.join(files.getDevBundle(), "bin", "npm"),
["install", "--force"], {cwd: dir}); ["install"], {cwd: dir});
if (! result.success) { if (! result.success) {
// XXX include this in the buildmessage.error instead // XXX include this in the buildmessage.error instead

View File

@@ -84,7 +84,7 @@ var _assertCorrectPackageNpmDir = function (deps) {
var expected = JSON.stringify({ var expected = JSON.stringify({
dependencies: expectedMeteorNpmShrinkwrapDependencies}, null, /*indentation, the way npm does it*/2) + '\n'; dependencies: expectedMeteorNpmShrinkwrapDependencies}, null, /*indentation, the way npm does it*/2) + '\n';
assert.equal(actual, expected); assert.equal(actual, expected, actual + " == " + expected);
assert.equal( assert.equal(
fs.readFileSync(path.join(testPackageDir, ".npm", "package", ".gitignore"), 'utf8'), fs.readFileSync(path.join(testPackageDir, ".npm", "package", ".gitignore"), 'utf8'),
@@ -203,7 +203,7 @@ var runTest = function () {
// just remove all of the .npm directory) // just remove all of the .npm directory)
var bareExecFileSync = meteorNpm._execFileSync; var bareExecFileSync = meteorNpm._execFileSync;
meteorNpm._execFileSync = function (file, args, opts) { meteorNpm._execFileSync = function (file, args, opts) {
if (args.length > 2 && args[0] === 'install' && args[1] === '--force') if (args.length > 1 && args[0] === 'install')
assert.fail("shouldn't be installing specific npm packages: " + args[1]); assert.fail("shouldn't be installing specific npm packages: " + args[1]);
return bareExecFileSync(file, args, opts); return bareExecFileSync(file, args, opts);
}; };