From 2ddc09bcacaefc11610c41b90df34f2cd9fc34d5 Mon Sep 17 00:00:00 2001 From: Ujjwal Sharma Date: Mon, 5 Mar 2018 23:48:45 +0530 Subject: [PATCH 1/2] get-metadata: fail with a non-zero exit status Fixes: https://github.com/nodejs/node-core-utils/issues/130 --- components/git/metadata.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/components/git/metadata.js b/components/git/metadata.js index 71c262f7..40b3f93e 100644 --- a/components/git/metadata.js +++ b/components/git/metadata.js @@ -83,15 +83,19 @@ function handler(argv) { const logStream = process.stdout.isTTY ? process.stdout : process.stderr; const cli = new CLI(logStream); - return getMetadata(Object.assign( - {}, config, argv, parsed - ), cli).catch((err) => { - if (cli.spinner.enabled) { - cli.spinner.fail(); - } - cli.error(err); - process.exit(-1); - }); + return getMetadata(Object.assign({}, config, argv, parsed), cli) + .then(({status}) => { + if (status === false) { + process.exit(1); + } + }) + .catch((err) => { + if (cli.spinner.enabled) { + cli.spinner.fail(); + } + cli.error(err); + process.exit(-1); + }); } module.exports = { From f64c874ccd9568d6724946fa09dee29f013b0844 Mon Sep 17 00:00:00 2001 From: Ujjwal Sharma Date: Tue, 6 Mar 2018 00:27:15 +0530 Subject: [PATCH 2/2] get-metadata: exiting via catch and throwing error in then --- components/git/metadata.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/git/metadata.js b/components/git/metadata.js index 40b3f93e..89be0455 100644 --- a/components/git/metadata.js +++ b/components/git/metadata.js @@ -86,7 +86,7 @@ function handler(argv) { return getMetadata(Object.assign({}, config, argv, parsed), cli) .then(({status}) => { if (status === false) { - process.exit(1); + throw new Error('PR checks failed'); } }) .catch((err) => { @@ -94,7 +94,7 @@ function handler(argv) { cli.spinner.fail(); } cli.error(err); - process.exit(-1); + process.exit(1); }); }