-
Notifications
You must be signed in to change notification settings - Fork 13
/
start.js
46 lines (36 loc) · 1.22 KB
/
start.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
44
45
46
const childProcess = require('child_process');
const menuBuilder = require('./runner-utils/menuBuilder');
const sharedUtils = require('./runner-utils/sharedUtils');
const gitTools = require('./runner-utils/gitTools');
let inquirer, clear;
try {
inquirer = require('inquirer');
clear = require('clear');
} catch (e) {
sharedUtils.logSetupError('It looks like the libraries we need aren\'t installed yet.');
process.exit(1);
}
gitTools.checkOutBranch('workspace');
function displayMainMenu() {
clear();
console.log('--- JS Learner Forms Main Menu ---\n\n');
const menuOptions = menuBuilder.buildMenuOptions();
const menuPrompt = menuBuilder.buildMenuPrompt(menuOptions);
inquirer
.prompt([
menuPrompt
])
.then(function (data) {
const selectedAction = menuOptions[data.selectedKey];
if (typeof selectedAction === 'string') {
const process = childProcess.fork(selectedAction);
process.on('close', function () {
displayMainMenu();
});
} else {
clear();
console.log('See you next time!');
}
});
}
displayMainMenu();