Skip to content

Commit

Permalink
fix: try to link latest version to top node_modules (#284)
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 authored Dec 11, 2018
1 parent e7f1f05 commit 20bbb17
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
10 changes: 4 additions & 6 deletions lib/local_install.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,10 @@ function* _install(options) {
options.spinner && options.spinner.succeed(`Installed ${tasks.length} packages`);

if (!options.disableDedupe) {
// don't link latest versions on `npminstall pkgName` way
if (options.pkgs.length === 0) {
// dedupe mode https://docs.npmjs.com/cli/dedupe
// link every packages' latest version to target directory
yield linkAllLatestVersion(rootPkgsMap, options);
}
// dedupe mode https://docs.npmjs.com/cli/dedupe
// link every packages' latest version to target directory
// won't override exists target directory
yield linkAllLatestVersion(rootPkgsMap, options);
} else {
options.spinner && options.spinner.succeed('disable dedupe mode');
}
Expand Down
5 changes: 3 additions & 2 deletions test/local-install-pkgs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ describe('test/local-install-pkgs.test.js', () => {
.end();
const names = fs.readdirSync(path.join(root, 'node_modules'))
.filter(n => !/^[\.\_]/.test(n));
assert(names.length === 1);
assert(names[0] === 'koa');
assert(names.length > 10);
assert(names.indexOf('koa') > 0);
assert(names.indexOf('accepts') >= 0);
});
});

0 comments on commit 20bbb17

Please sign in to comment.