-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathrun.js
executable file
·43 lines (30 loc) · 897 Bytes
/
run.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env node
/**
* This replicates `yarn workspaces run ...`,
* but allows running subsets of workspaces.
*/
'use strict';
const path = require('path');
const [packagePrefix, scriptName, ...args] = process.argv.slice(2);
const root = path.resolve(__dirname, '..');
(async () => {
const { $, execa } = await import('execa');
let cp = await $`yarn --silent workspaces info`;
let json = JSON.parse(cp.stdout);
let promises = Object.values(json).map(({ location }) => async () => {
if (!location.startsWith(packagePrefix)) {
return;
}
let cwd = path.join(root, location);
console.log(location);
await execa('yarn', [scriptName, ...args], {
cwd,
stdio: 'inherit',
});
});
const { default: pAll } = await import('p-all');
await pAll(promises, {
concurrency: 1,
});
})();
require('../packages/cli/src/utils/throw-up');