From d2b19ac6c8ca052dd31d292c51ab113590cda71a Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Pasquier Date: Mon, 8 Mar 2021 15:34:34 +0100 Subject: [PATCH] cicd: exit code --- internal/parcel.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/internal/parcel.js b/internal/parcel.js index 040c650..d584901 100644 --- a/internal/parcel.js +++ b/internal/parcel.js @@ -25,9 +25,9 @@ const options = { autoInstall: true }; -(async function() { +((async function () { let configPath = process.env.CONFIG_PATH || 'config.json'; - if(!fs.existsSync(configPath)) throw `[Error] (Mandatory) Missing ${configPath} file`; + if (!fs.existsSync(configPath)) throw console.error(Error(`(Mandatory) Missing ${configPath} file`)); console.log(`Using ${configPath} config file`); let config = JSON.parse(fs.readFileSync(configPath)); @@ -68,9 +68,11 @@ const options = { const bundler = new Bundler('./src/index.pug', options); bundler.addAssetType('html', require.resolve('./assets.js')); - if(process.env.NODE_ENV !== 'production') { + if (process.env.NODE_ENV !== 'production') { await bundler.serve(); } else { await bundler.bundle(); } -})(); \ No newline at end of file +})()).catch((e) => { + process.exitCode = 1; +}); \ No newline at end of file