|
1 | 1 | const libexec = require('libnpmexec') |
2 | 2 | const BaseCommand = require('../base-command.js') |
3 | | -const getLocationMsg = require('../exec/get-workspace-location-msg.js') |
4 | | - |
5 | | -// it's like this: |
6 | | -// |
7 | | -// npm x pkg@version <-- runs the bin named "pkg" or the only bin if only 1 |
8 | | -// |
9 | | -// { name: 'pkg', bin: { pkg: 'pkg.js', foo: 'foo.js' }} <-- run pkg |
10 | | -// { name: 'pkg', bin: { foo: 'foo.js' }} <-- run foo? |
11 | | -// |
12 | | -// npm x -p pkg@version -- foo |
13 | | -// |
14 | | -// npm x -p pkg@version -- foo --registry=/dev/null |
15 | | -// |
16 | | -// const pkg = npm.config.get('package') || getPackageFrom(args[0]) |
17 | | -// const cmd = getCommand(pkg, args[0]) |
18 | | -// --> npm x -c 'cmd ...args.slice(1)' |
19 | | -// |
20 | | -// we've resolved cmd and args, and escaped them properly, and installed the |
21 | | -// relevant packages. |
22 | | -// |
23 | | -// Add the ${npx install prefix}/node_modules/.bin to PATH |
24 | | -// |
25 | | -// pkg = readPackageJson('./package.json') |
26 | | -// pkg.scripts.___npx = ${the -c arg} |
27 | | -// runScript({ pkg, event: 'npx', ... }) |
28 | | -// process.env.npm_lifecycle_event = 'npx' |
29 | 3 |
|
30 | 4 | class Exec extends BaseCommand { |
31 | 5 | static description = 'Run a command from a local or remote npm package' |
@@ -64,7 +38,7 @@ class Exec extends BaseCommand { |
64 | 38 | localBin, |
65 | 39 | globalBin, |
66 | 40 | } = this.npm |
67 | | - const output = (...outputArgs) => this.npm.output(...outputArgs) |
| 41 | + const output = this.npm.output.bind(this.npm) |
68 | 42 | const scriptShell = this.npm.config.get('script-shell') || undefined |
69 | 43 | const packages = this.npm.config.get('package') |
70 | 44 | const yes = this.npm.config.get('yes') |
@@ -94,10 +68,10 @@ class Exec extends BaseCommand { |
94 | 68 |
|
95 | 69 | async execWorkspaces (args, filters) { |
96 | 70 | await this.setWorkspaces(filters) |
97 | | - const color = this.npm.color |
98 | 71 |
|
99 | | - for (const path of this.workspacePaths) { |
100 | | - const locationMsg = await getLocationMsg({ color, path }) |
| 72 | + for (const [name, path] of this.workspaces) { |
| 73 | + const locationMsg = |
| 74 | + `in workspace ${this.npm.chalk.green(name)} at location:\n${this.npm.chalk.dim(path)}` |
101 | 75 | await this.exec(args, { locationMsg, runPath: path }) |
102 | 76 | } |
103 | 77 | } |
|
0 commit comments