Skip to content

Commit

Permalink
fix: update cli should ignore package names args
Browse files Browse the repository at this point in the history
closes #181
  • Loading branch information
fengmk2 committed Jan 17, 2017
1 parent 9f15e53 commit 8b1ef18
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions bin/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
3 changes: 3 additions & 0 deletions bin/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
16 changes: 15 additions & 1 deletion test/update.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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();
});
});
});

0 comments on commit 8b1ef18

Please sign in to comment.