From 1697c561e8edc613d6087ab2ec84ab7617c0c1e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Gra=C3=A7a?= Date: Mon, 25 May 2020 19:40:35 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20test=20when=20in=20--dry-?= =?UTF-8?q?run=20mode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tests failed when in --dry-run mode because it was checking if there was actual files changed --- lib/cli.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/cli.js b/lib/cli.js index d9be30ad..9429a179 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -27,25 +27,25 @@ const executeCommand = (command, args = [], env = process.env) => { const main = async () => { try { - try { - /** - * @author https://github.com/rodrigograca31 - * @see https://github.com/streamich/git-cz/issues/177 - * - * It exits with 1 if there were differences and 0 means no differences. - * Because of that we negate it to only throw an error if there's no files staged - * https://stackoverflow.com/questions/367069/how-can-i-negate-the-return-value-of-a-process - */ - execSync('! git diff HEAD --staged --quiet --exit-code'); - } catch (error) { - throw new Error('No files staged.'); - } - const {cliAnswers, cliOptions, passThroughParams} = parseArgs(); if (cliOptions.dryRun) { // eslint-disable-next-line no-console console.log('Running in dry mode.'); + } else { + try { + /** + * @author https://github.com/rodrigograca31 + * @see https://github.com/streamich/git-cz/issues/177 + * + * It exits with 1 if there were differences and 0 means no differences. + * Because of that we negate it to only throw an error if there's no files staged + * https://stackoverflow.com/questions/367069/how-can-i-negate-the-return-value-of-a-process + */ + execSync('! git diff HEAD --staged --quiet --exit-code'); + } catch (error) { + throw new Error('No files staged.'); + } } const state = createState({disableEmoji: cliOptions.disableEmoji});