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

Commit

Permalink
fix: 🐛 test when in --dry-run mode
Browse files Browse the repository at this point in the history
tests failed when in --dry-run mode because it was checking if there was
actual files changed
  • Loading branch information
rodrigograca31 committed May 25, 2020
1 parent c283ad3 commit 1697c56
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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});
Expand Down

0 comments on commit 1697c56

Please sign in to comment.