-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.js
26 lines (23 loc) · 679 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
const spawn = require('child_process').spawn;
const path = require('path');
const exec = (cmd, args=[]) => new Promise((resolve, reject) => {
console.log(`Started: ${cmd} ${args.join(" ")}`);
const app = spawn(cmd, args, { stdio: 'inherit' });
app.on('close', code => {
if (code !== 0) {
const err = new Error(`Invalid status code: ${code}`);
err.code = code;
return reject(err);
}
return resolve(code);
});
app.on('error', reject);
});
const main = async () => {
await exec('bash', [path.join(__dirname, './action.sh')]);
};
main().catch(err => {
console.error(err);
console.error(err.stack);
process.exit(err.code || -1);
});