Skip to content

Commit

Permalink
feat: Fail on fix (prettier#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
josejulio committed Dec 12, 2018
1 parent 157d4b1 commit 78a715d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -92,6 +92,10 @@ When not in `staged` pre-commit mode, use this flag to compare changes with the

Outputs the name of each file right before it is proccessed. This can be useful if Prettier throws an error and you can't identify which file is causing the problem.

## `--fail-on-fix`

Makes pretty-quick to exit with a non-zero exit code if any file is fixed. The intent is to abort the git commit.

<!-- Undocumented = Unsupported :D
### `--config`
Expand Down
10 changes: 9 additions & 1 deletion bin/pretty-quick.js
Expand Up @@ -7,7 +7,12 @@ const mri = require('mri');

const prettyQuick = require('..').default;

const args = mri(process.argv.slice(2));
const args = mri(process.argv.slice(2), {
boolean: ['fail-on-fix'],
default: { 'fail-on-fix': false },
});

const failOnFix = args['fail-on-fix'];

let success = true;
prettyQuick(
Expand Down Expand Up @@ -36,6 +41,9 @@ prettyQuick(

onWriteFile: file => {
console.log(`✍️ Fixing up ${chalk.bold(file)}.`);
if (failOnFix) {
success = false;
}
},

onExamineFile: file => {
Expand Down

0 comments on commit 78a715d

Please sign in to comment.