-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathdev.ts
More file actions
56 lines (45 loc) · 1.4 KB
/
dev.ts
File metadata and controls
56 lines (45 loc) · 1.4 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
import * as p from '@clack/prompts';
import { spawn } from 'node:child_process';
import { filterByScript, getWorkspacePackages } from './lib/workspace';
const main = async () => {
p.intro('Dev CLI');
const packages = getWorkspacePackages();
const devPackages = filterByScript(packages, 'dev');
if (devPackages.length === 0) {
p.cancel('No packages with a `dev` script found.');
process.exit(0);
}
// Single package: skip prompt and auto-select
const selected: string[] =
devPackages.length === 1
? [devPackages[0].name]
: await (async () => {
const result = await p.multiselect({
message: 'Which packages to run in dev mode?',
options: devPackages.map(pkg => ({
value: pkg.name,
label: pkg.name,
hint: pkg.dir,
})),
required: true,
});
if (p.isCancel(result)) {
p.cancel('Cancelled.');
process.exit(0);
}
return result as string[];
})();
const filters = selected.map(name => `--filter=${name}...`).join(' ');
p.outro(`Running: turbo dev check-types:watch ${filters}`);
const child = spawn(
'turbo',
['dev', 'check-types:watch', ...filters.split(' ')],
{
cwd: process.cwd(),
stdio: 'inherit',
shell: true,
}
);
child.on('exit', code => process.exit(code ?? 0));
};
main();