UNPKG

563 BJavaScriptView Raw
1const path = require('path');
2const taskify = require('../cli-task');
3const runPackage = require('../run-package');
4
5function 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
14exports.task = script;
15
16exports.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};