git-auto-commit-action/index.js

27 lines
722 B
JavaScript
Raw Normal View History

2020-02-12 04:04:18 +08:00
const spawn = require('child_process').spawn;
const path = require("path");
2020-02-12 03:50:33 +08:00
2020-02-12 04:04:18 +08:00
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){
err = new Error(`Invalid status code: ${code}`);
err.code = code;
return reject(err);
};
return resolve(code);
});
app.on('error', reject);
});
2020-02-12 03:50:33 +08:00
2020-02-12 04:04:18 +08:00
const main = async () => {
2020-02-23 17:16:26 +08:00
await exec('bash', [path.join(__dirname, './entrypoint.sh')]);
2020-02-12 04:04:18 +08:00
};
main().catch(err => {
console.error(err);
console.error(err.stack);
process.exit(err.code || -1);
})