mirror of
https://github.com/stefanzweifel/git-auto-commit-action.git
synced 2024-12-06 02:09:04 +00:00
Simplify index.js
This commit is contained in:
parent
844e852dde
commit
eda98fb9e5
@ -37,7 +37,7 @@ inputs:
|
||||
|
||||
runs:
|
||||
using: 'node12'
|
||||
main: 'dist/index.js'
|
||||
main: 'index.js'
|
||||
|
||||
branding:
|
||||
icon: 'git-commit'
|
||||
|
35
index.js
35
index.js
@ -1,13 +1,26 @@
|
||||
const core = require('@actions/core');
|
||||
const exec = require('@actions/exec');
|
||||
const spawn = require('child_process').spawn;
|
||||
const path = require("path");
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
await exec.exec('sh', ['entrypoint.sh']);
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
}
|
||||
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);
|
||||
});
|
||||
|
||||
run()
|
||||
const main = async () => {
|
||||
await exec('sh', [path.join(__dirname, './entrypoint.sh')]);
|
||||
};
|
||||
|
||||
main().catch(err => {
|
||||
console.error(err);
|
||||
console.error(err.stack);
|
||||
process.exit(err.code || -1);
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user