fix(cli): do not early exit for `--debug-check` (#2987)
* test: add failing test * fix(cli): do not early exit for `--debug-check`master
parent
23f7e92162
commit
6c8cde9672
|
@ -58,14 +58,12 @@ function handleError(filename, error) {
|
|||
// parser has mistakenly thrown arrays sometimes.)
|
||||
if (isParseError) {
|
||||
console.error(`${filename}: ${String(error)}`);
|
||||
} else if (
|
||||
isValidationError ||
|
||||
error instanceof errors.ConfigError ||
|
||||
error instanceof errors.DebugError
|
||||
) {
|
||||
} else if (isValidationError || error instanceof errors.ConfigError) {
|
||||
console.error(String(error));
|
||||
// If validation fails for one file, it will fail for all of them.
|
||||
process.exit(1);
|
||||
} else if (error instanceof errors.DebugError) {
|
||||
console.error(`${filename}: ${error.message}`);
|
||||
} else {
|
||||
console.error(filename + ":", error.stack || error);
|
||||
}
|
||||
|
|
|
@ -3,3 +3,65 @@
|
|||
exports[`checks stdin with --debug-check (write) 1`] = `Array []`;
|
||||
|
||||
exports[`doesn't crash when --debug-check is passed (write) 1`] = `Array []`;
|
||||
|
||||
exports[`show diff for 2+ error files with --debug-check (stderr) 1`] = `
|
||||
"a.js: ast(input) !== ast(prettier(input))
|
||||
Index:
|
||||
===================================================================
|
||||
---
|
||||
+++
|
||||
@@ -17,6 +17,6 @@
|
||||
\\"method\\": false,
|
||||
\\"key\\": {
|
||||
- \\"type\\": \\"StringLiteral\\",
|
||||
- \\"value\\": \\"a\\"
|
||||
+ \\"type\\": \\"Identifier\\",
|
||||
+ \\"name\\": \\"a\\"
|
||||
},
|
||||
\\"computed\\": false,
|
||||
|
||||
Index:
|
||||
===================================================================
|
||||
---
|
||||
+++
|
||||
@@ -1,3 +1,3 @@
|
||||
const a = {
|
||||
- 'a': 1
|
||||
+ a: 1
|
||||
};
|
||||
|
||||
b.js: ast(input) !== ast(prettier(input))
|
||||
Index:
|
||||
===================================================================
|
||||
---
|
||||
+++
|
||||
@@ -17,6 +17,6 @@
|
||||
\\"method\\": false,
|
||||
\\"key\\": {
|
||||
- \\"type\\": \\"StringLiteral\\",
|
||||
- \\"value\\": \\"b\\"
|
||||
+ \\"type\\": \\"Identifier\\",
|
||||
+ \\"name\\": \\"b\\"
|
||||
},
|
||||
\\"computed\\": false,
|
||||
|
||||
Index:
|
||||
===================================================================
|
||||
---
|
||||
+++
|
||||
@@ -1,3 +1,3 @@
|
||||
const b = {
|
||||
- 'b': 2
|
||||
+ b: 2
|
||||
};
|
||||
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`show diff for 2+ error files with --debug-check (stdout) 1`] = `
|
||||
"
|
||||
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`show diff for 2+ error files with --debug-check (write) 1`] = `Array []`;
|
||||
|
|
|
@ -19,3 +19,9 @@ describe("checks stdin with --debug-check", () => {
|
|||
status: 0
|
||||
});
|
||||
});
|
||||
|
||||
describe("show diff for 2+ error files with --debug-check", () => {
|
||||
runPrettier("cli/debug-check", ["*.js", "--debug-check"]).test({
|
||||
status: "non-zero"
|
||||
});
|
||||
});
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
const a = {
|
||||
'a': 1
|
||||
};
|
|
@ -0,0 +1,3 @@
|
|||
const b = {
|
||||
'b': 2
|
||||
};
|
Loading…
Reference in New Issue