Skip to content

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

1 comment on commit 78dec95

@streamich
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build version: 4.5.0-staged-files-check.825 🀞 staged-files-check on Travis πŸŽ‰

Please sign in to comment.