cicd: exit code

This commit is contained in:
Jean-Baptiste Pasquier 2021-03-08 15:34:34 +01:00
parent ccc9d24d09
commit d2b19ac6c8
1 changed files with 6 additions and 4 deletions

View File

@ -25,9 +25,9 @@ const options = {
autoInstall: true autoInstall: true
}; };
(async function() { ((async function () {
let configPath = process.env.CONFIG_PATH || 'config.json'; 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`); console.log(`Using ${configPath} config file`);
let config = JSON.parse(fs.readFileSync(configPath)); let config = JSON.parse(fs.readFileSync(configPath));
@ -68,9 +68,11 @@ const options = {
const bundler = new Bundler('./src/index.pug', options); const bundler = new Bundler('./src/index.pug', options);
bundler.addAssetType('html', require.resolve('./assets.js')); bundler.addAssetType('html', require.resolve('./assets.js'));
if(process.env.NODE_ENV !== 'production') { if (process.env.NODE_ENV !== 'production') {
await bundler.serve(); await bundler.serve();
} else { } else {
await bundler.bundle(); await bundler.bundle();
} }
})(); })()).catch((e) => {
process.exitCode = 1;
});