From 1bf41a92a1d1808480fea85dcc503e02e0952947 Mon Sep 17 00:00:00 2001 From: Adam Dobrawy Date: Sat, 2 Jan 2021 06:50:13 +0100 Subject: [PATCH] Revert "refactor(start): use @actions/exec (#47)" (#73) This reverts commit c52e809b5674f36e38bf83f07568dbf04f7921d4. --- start.js | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/start.js b/start.js index 24d3b02..0e10b40 100644 --- a/start.js +++ b/start.js @@ -1,12 +1,26 @@ -const exec = require("@actions/exec"); +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){ + 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(path.join(__dirname, "./start.sh")); + await exec('bash', [path.join(__dirname, './start.sh')]); }; main().catch(err => { - console.error(err); - console.error(err.stack); - process.exit(err.code || -1); -}); + console.error(err); + console.error(err.stack); + process.exit(err.code || -1); +})