1 | const path = require('path');
|
2 | const taskify = require('../cli-task');
|
3 | const runPackage = require('../run-package');
|
4 |
|
5 | function script(packages = [], scriptPath) {
|
6 | const resolvedScript = path.resolve(process.cwd(), scriptPath);
|
7 |
|
8 | return packages.map(pkg => {
|
9 | const apply = () => runPackage('node', [resolvedScript], pkg.location);
|
10 | return { pkg, apply };
|
11 | });
|
12 | }
|
13 |
|
14 | exports.task = script;
|
15 |
|
16 | exports.register = program => {
|
17 | program
|
18 | .command('script <path>')
|
19 | .description('Runs the given Node script in the scope of each package')
|
20 | .action(taskify(script));
|
21 | };
|