-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.ts
50 lines (41 loc) · 1022 Bytes
/
app.ts
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
import inquirer from 'inquirer';
import { exec } from 'child_process';
const menuOptions = [
{
name: 'Ejecutar CHALLENGE_01',
value: 'run_challenge_01',
},
{
name: 'Salir',
value: 'exit',
},
] as const;
const menuQuestions = [
{
type: 'list',
name: 'menuOption',
message: 'Seleccione una opción:',
choices: menuOptions,
},
] as const;
const options = {
"run_challenge_01": "cd dist/CHALLENGE_01 && node solution.js",
}
inquirer.prompt(menuQuestions).then((answers) => {
const option = options[answers.menuOption] || null;
if (!option) {
console.log('Saliendo del menú...')
return;
};
exec(option, (error, stdout, stderr) => {
if (error) {
console.error(`Error: ${error.message}`);
return;
}
if (stderr) {
console.error(`Error: ${stderr}`);
return;
}
console.log(`Resultado: ${stdout}`);
});
});