-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathindex.js
More file actions
80 lines (60 loc) · 1.65 KB
/
index.js
File metadata and controls
80 lines (60 loc) · 1.65 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
const ora = require('ora');
const {install, remove} = require('./lib/installer');
const {start} = require('./lib/starter');
class StepFunctions {
constructor({quiet = false, path = './.step-functions-local'} = {}) {
this.quiet = quiet;
this.path = path;
}
async install() {
let spinner;
if (!this.quiet) {
spinner = ora('Downloading Step Functions Local...').start();
}
try {
await install(this.path);
} catch (error) {
if (!this.quiet) {
spinner.fail('Download failed.');
}
throw error;
}
if (!this.quiet) {
spinner.succeed('Downloaded Step Functions Local.');
}
}
remove() {
return remove(this.path);
}
start(options = {}) {
let spinner;
if (!this.quiet) {
spinner = ora('Starting Step Functions Local...').start();
}
this.instance = start({...options, path: this.path});
this.instance.process.on('close', code => {
if (code !== null && code !== 0 && !this.quiet) {
console.log('Step Functions Local failed to start with code', code);
}
});
if (!this.quiet) {
spinner.succeed('Step Functions Local started: http://localhost:8083');
}
return this.instance.process.stdout;
}
stop() {
if (!this.instance) {
throw new Error('Step Functions Local instance not running');
}
let spinner;
if (!this.quiet) {
spinner = ora('Stopping Step Functions Local...').start();
}
this.instance.process.kill('SIGKILL');
this.instance = undefined;
if (!this.quiet) {
spinner.succeed('Step Functions Local stopped.');
}
}
}
module.exports = StepFunctions;