-
Notifications
You must be signed in to change notification settings - Fork 2
/
start.js
46 lines (36 loc) · 1.02 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
let fs;
let readline;
let inquirer;
try {
fs = require('fs');
readline = require('readline');
inquirer = require('inquirer');
} catch (e) {
console.log(`🙁 Packages missing, run 'npm install' / 'yarn install' first`);
process.exit(0);
}
// Require questions
const questions = require('./_config/questions');
// Require global config
const config = require('./_config/config');
// Require the setup tool
const tool = require('./setup');
let setups = [];
// Start application by checking which setups are available
fs.readdir('./_viewlayers', (err, files) => {
files.forEach((file) => {
if (!file.match(/^\s*?\..*$/)) {
setups.push(file);
};
});
setups.push(new inquirer.Separator(), config.questions.requestGitUrl);
const finalQuestions = questions.getQuestions(setups);
askQuestions(finalQuestions);
});
// Callback => handleAnswers
const askQuestions = (finalQuestions) => {
inquirer.prompt(finalQuestions).then(handleAnswers);
};
const handleAnswers = (answers) => {
tool.start(answers);
};