| 44 | } |
| 45 | |
| 46 | async exec (args) { |
| 47 | if (this.npm.global) { |
| 48 | throw Object.assign( |
| 49 | new Error( |
| 50 | 'link should never be --global.\n' + |
| 51 | 'Please re-run this command with --local' |
| 52 | ), |
| 53 | { code: 'ELINKGLOBAL' } |
| 54 | ) |
| 55 | } |
| 56 | // install-links is implicitly false when running `npm link` |
| 57 | this.npm.config.set('install-links', false) |
| 58 | |
| 59 | // link with no args: symlink the folder to the global location |
| 60 | // link with package arg: symlink the global to the local |
| 61 | args = args.filter(a => resolve(a) !== this.npm.prefix) |
| 62 | return args.length |
| 63 | ? this.linkInstall(args) |
| 64 | : this.linkPkg() |
| 65 | } |
| 66 | |
| 67 | async linkInstall (args) { |
| 68 | // load current packages from the global space, and then add symlinks installs locally |