pretty-quick
Advanced tools
Comparing version 1.10.0 to 1.11.0
@@ -39,2 +39,8 @@ #!/usr/bin/env node | ||
onCheckFile: (file, isFormatted) => { | ||
if (!isFormatted) { | ||
console.log(`⛔️ Check failed: ${chalk.bold(file)}`); | ||
} | ||
}, | ||
onExamineFile: file => { | ||
@@ -60,3 +66,8 @@ console.log(`🔍 Examining ${chalk.bold(file)}.`); | ||
} | ||
if (prettyQuickResult.errors.indexOf('CHECK_FAILED') !== -1) { | ||
console.log( | ||
'✗ Code style issues found in the above file(s). Forgot to run Prettier?' | ||
); | ||
} | ||
process.exit(1); // ensure git hooks abort | ||
} |
@@ -11,5 +11,5 @@ 'use strict'; | ||
var _formatFiles = require('./formatFiles'); | ||
var _processFiles = require('./processFiles'); | ||
var _formatFiles2 = _interopRequireDefault(_formatFiles); | ||
var _processFiles2 = _interopRequireDefault(_processFiles); | ||
@@ -38,2 +38,3 @@ var _createIgnorer = require('./createIgnorer'); | ||
bail, | ||
check, | ||
verbose, | ||
@@ -43,4 +44,5 @@ onFoundSinceRevision, | ||
onPartiallyStagedFile, | ||
onWriteFile, | ||
onExamineFile | ||
onExamineFile, | ||
onCheckFile, | ||
onWriteFile | ||
} = {}) => { | ||
@@ -70,3 +72,4 @@ const scm = (0, _scms2.default)(currentDirectory); | ||
(0, _formatFiles2.default)(directory, changedFiles, { | ||
(0, _processFiles2.default)(directory, changedFiles, { | ||
check, | ||
config, | ||
@@ -87,2 +90,8 @@ onWriteFile: file => { | ||
}, | ||
onCheckFile: (file, isFormatted) => { | ||
onCheckFile && onCheckFile(file, isFormatted); | ||
if (!isFormatted) { | ||
failReasons.add('CHECK_FAILED'); | ||
} | ||
}, | ||
onExamineFile: verbose && onExamineFile | ||
@@ -89,0 +98,0 @@ }); |
{ | ||
"name": "pretty-quick", | ||
"version": "1.10.0", | ||
"version": "1.11.0", | ||
"description": "Get Pretty Quick", | ||
@@ -5,0 +5,0 @@ "repository": "azz/pretty-quick", |
@@ -100,6 +100,10 @@ # `pretty-quick` | ||
## `--bail` | ||
### `--bail` | ||
Prevent `git commit` if any files are fixed. | ||
### `--check` | ||
Check that files are correctly formatted, but don't format them. This is useful on CI to verify that all changed files in the current branch were correctly formatted. | ||
<!-- Undocumented = Unsupported :D | ||
@@ -106,0 +110,0 @@ |
47934
294
125