From fe38f0a751bf9149f0270cc1fe20bf9156854365 Mon Sep 17 00:00:00 2001 From: Adam Dobrawy Date: Tue, 4 Feb 2020 00:51:06 +0100 Subject: [PATCH] Update start.js for pass code from start.sh (#45) --- .github/workflows/build.yml | 2 +- start.js | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1abd4be..d4cedd3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,4 +15,4 @@ jobs: uses: './' with: github_token: '${{ secrets.GITHUB_TOKEN }}' - branch: '${{ github.ref }}' \ No newline at end of file + branch: '${{ github.ref }}' diff --git a/start.js b/start.js index 49addcd..0e10b40 100644 --- a/start.js +++ b/start.js @@ -4,7 +4,14 @@ 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', resolve); + 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); }); @@ -15,5 +22,5 @@ const main = async () => { main().catch(err => { console.error(err); console.error(err.stack); - process.exit(-1); -}) \ No newline at end of file + process.exit(err.code || -1); +})