diff --git a/bin/install.js b/bin/install.js index c6cd0cfd..7fd91ae0 100755 --- a/bin/install.js +++ b/bin/install.js @@ -99,6 +99,11 @@ Options: const pkgs = []; +if (process.env.NPMINSTALL_BY_UPDATE) { + // ignore all package names on update + argv._ = []; +} + for (const name of argv._) { const p = npa(String(name)); pkgs.push({ name: p.name, version: p.rawSpec, type: p.type }); diff --git a/bin/update.js b/bin/update.js index d5b33724..b25007ae 100755 --- a/bin/update.js +++ b/bin/update.js @@ -25,6 +25,9 @@ const nodeModules = path.join(root, 'node_modules'); console.log('[npmupdate] removing %s', nodeModules); rimraf.sync(nodeModules); console.log('[npmupdate] reinstall on %s', root); + +// make sure install ignore all package names +process.env.NPMINSTALL_BY_UPDATE = 'true'; require('./install'); function help() { diff --git a/test/update.test.js b/test/update.test.js index 3326da44..b9bd4c92 100644 --- a/test/update.test.js +++ b/test/update.test.js @@ -27,7 +27,7 @@ describe('test/update.test.js', () => { afterEach(cleanup); - it('should uninstall ok', done => { + it('should update ok', done => { coffee.fork(npmupdate, [], { cwd: root, stdio: 'pipe', @@ -40,4 +40,18 @@ describe('test/update.test.js', () => { done(); }); }); + + it('should update pedding ok', done => { + coffee.fork(npmupdate, [ 'pedding' ], { + cwd: root, + stdio: 'pipe', + }) + .debug() + .end(err => { + assert(!err); + assert(fs.existsSync(path.join(root, 'node_modules/pedding'))); + assert(fs.existsSync(path.join(root, 'node_modules/pkg'))); + done(); + }); + }); });