Skip to content
This repository has been archived by the owner on Jun 16, 2021. It is now read-only.

Commit

Permalink
fix: πŸ› check for staged files
Browse files Browse the repository at this point in the history
removes use of ! and shows warning instead of error
  • Loading branch information
rodrigograca31 committed May 26, 2020
1 parent 1697c56 commit 78dec95
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down

0 comments on commit 78dec95

Please sign in to comment.