diff --git a/.gitignore b/.gitignore index 794d0d3..fa5f0b7 100644 --- a/.gitignore +++ b/.gitignore @@ -112,4 +112,5 @@ out .yarn/unplugged .yarn/build-state.yml .yarn/install-state.gz -.pnp.* \ No newline at end of file +.pnp.* +response.json diff --git a/exec.js b/exec.js index 1ec22cd..6a52606 100644 --- a/exec.js +++ b/exec.js @@ -9,15 +9,30 @@ const exec = (cmd, args = [], options = {}) => new Promise((resolve, reject) => Object.assign(optionsToCLI, {stdio: ['inherit', 'inherit', 'inherit']}); } const app = spawn(cmd, args, optionsToCLI); - app.on('close', (code) => { + app.on('close', code => { if (code !== 0) { - const err = new Error(`Invalid status code: ${code}`); - err.code = code; - return reject(err); + reject(new Error(`Command "${cmd} ${args.join(' ')}" exited with code ${code}`)); + return; } - return resolve(code); - }); - app.on('error', reject); + resolve(); + } + ); + + app.on('error', error => { + reject(error); + } + ); + + app.on('exit', code => { + if (code !== 0) { + reject(new Error(`Command "${cmd} ${args.join(' ')}" exited with code ${code}`)); + return; + } + resolve(); + } + ); + + }); module.exports = exec; \ No newline at end of file diff --git a/index.js b/index.js index a450b45..2f3dd63 100644 --- a/index.js +++ b/index.js @@ -4,7 +4,7 @@ const Humanize = require("humanize-plus"); const fs = require("fs"); const exec = require("./exec"); -const TODOIST_API_KEY = core.getInput("TODOIST_API_KEY"); +const TODOIST_API_KEY = core.getInput("TODOIST_API_KEY") || process.env.TODOIST_API_KEY; const PREMIUM = core.getInput("PREMIUM"); async function main() { @@ -128,4 +128,4 @@ const commitReadme = async () => { (async () => { await main(); -})(); +})(); \ No newline at end of file