-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathselect.js
43 lines (36 loc) · 1.1 KB
/
select.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
const { default: inquirer } = require('inquirer');
const { spawn } = require('child_process');
const questions = [
{
type: 'list',
name: 'file',
message: 'Whats the project you want to run?:',
choices: ['user', 'admin', 'ui', 'design-token'],
},
];
inquirer.prompt(questions).then((answers) => {
let command, args;
if (answers.file === 'user') {
command = 'yarn';
args = ['workspace', '@mozu/user', 'run', 'start'];
} else if (answers.file === 'admin') {
command = 'yarn';
args = ['workspace', '@mozu/admin', 'run', 'start'];
} else if (answers.file === 'ui') {
command = 'yarn';
args = ['workspace', '@mozu/ui', 'run', 'start'];
} else if (answers.file === 'design-token') {
command = 'yarn';
args = ['workspace', '@mozu/design-token', 'run', 'start'];
}
const child = spawn(command, args, { shell: true });
child.stdout.on('data', (data) => {
console.log(`${data}`);
});
child.stderr.on('data', (data) => {
console.error(`${data}`);
});
child.on('close', (code) => {
console.log(`Child process exited with code ${code}`);
});
});