-
Notifications
You must be signed in to change notification settings - Fork 15
/
index.js
35 lines (30 loc) · 883 Bytes
/
index.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
const exec = require('child_process').exec;
const path = require('path');
function executeCommand(cmd, workingDirectory = null) {
return new Promise((resolve, reject) => {
let options = {};
if (workingDirectory) {
options.cwd = path.resolve(workingDirectory);
}
let p = exec(cmd, options, (error, stdout, stderr) => {
if (error) {
reject(error);
}
resolve(stdout ? stdout : stderr);
});
p.stdout.pipe(process.stdout);
p.stderr.pipe(process.stderr);
});
}
async function main() {
await executeCommand('npm ci --only=prod', __dirname);
await require('./main').main();
}
if (require.main === module) {
main()
.then(() => process.exit(0))
.catch(e => {
console.error(e);
process.exit(1);
});
}