forked from mschmidt712/kubernetes-ci-cd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.js
executable file
·52 lines (45 loc) · 1.36 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
47
48
49
50
51
52
#!/usr/bin/node
YAML = require('yamljs');
var inquirer = require('inquirer');
var Rx = require('rx');
var prompts = new Rx.Subject();
const execSync = require('child_process').execSync;
var ymlpath = process.argv[2];
inquirer.prompt(prompts).ui.process.subscribe(
function(answers) {
if(answers.hasOwnProperty('answer') && answers['answer'] === true){
execSync(answers.name, {
stdio: [0, 1, 2],
env: process.env
})
} else {
console.log('Skipping execution of: ', answers.name)
}
},
function(err) {
console.log('error')
},
function(message) {
console.log('complete')
}
);
prompts.onNext({
type: 'confirm',
name: ":",
message: "Welcome to the Linux.com interactive Kubernetes tutorial by Kenzan. Press enter to begin\n",
default: true
});
YAML.load(ymlpath, function(docs) {
var stepIndex = 1;
docs.parts.forEach(function(item) {
item.steps.forEach(function(step) {
prompts.onNext({
type: 'confirm',
name: step.com,
message: "\n\n\n" + item.name + " Step: " + stepIndex++ + "\n" + step.cap + "\n\n" + step.com + "\n\nPress enter to run the above command for the step.",
default: true
});
})
})
prompts.onCompleted();
});