From 78dec9516b56cda86727534c76cf4f20f4f008c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Gra=C3=A7a?= Date: Tue, 26 May 2020 22:20:25 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20check=20for=20staged=20fi?= =?UTF-8?q?les?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit removes use of ! and shows warning instead of error --- lib/cli.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/cli.js b/lib/cli.js index 9429a179..06193bef 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -38,13 +38,14 @@ const main = async () => { * @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 + * Exits with 1 if there are differences and 0 if no differences. */ - execSync('! git diff HEAD --staged --quiet --exit-code'); + execSync('git diff HEAD --staged --quiet --exit-code'); + + // Executes the following line only if the one above didn't crash (exit code: 0) + signale.warn('No files staged!'); } catch (error) { - throw new Error('No files staged.'); + // eslint-disable no-empty } }