ensure --list-different + --write reports status code 0 (#5512)
* change exit code for list different and write * update existing testsmaster
parent
7da4ed76ad
commit
e12cd17be2
|
@ -146,9 +146,9 @@ function listDifferent(context, input, options, filename) {
|
|||
if (!prettier.check(input, options)) {
|
||||
if (!context.argv["write"]) {
|
||||
context.logger.log(filename);
|
||||
}
|
||||
process.exitCode = 1;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
context.logger.error(error.message);
|
||||
}
|
||||
|
@ -498,8 +498,10 @@ function formatFiles(context) {
|
|||
|
||||
if (context.argv["list-different"] && isDifferent) {
|
||||
context.logger.log(filename);
|
||||
if (!context.argv["write"]) {
|
||||
process.exitCode = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (context.argv["write"]) {
|
||||
if (process.stdout.isTTY) {
|
||||
|
|
|
@ -113,7 +113,7 @@ describe("--write and --list-different with unknown path and no parser", () => {
|
|||
|
||||
describe("multiple files", () => {
|
||||
runPrettier("cli/infer-parser/", ["--list-different", "--write", "*"]).test(
|
||||
{ status: 1 }
|
||||
{ status: 0 }
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -8,7 +8,7 @@ describe("output with --list-different + unformatted differs when piped", () =>
|
|||
["--write", "--list-different", "--no-color", "unformatted.js"],
|
||||
{ stdoutIsTTY: true }
|
||||
).test({
|
||||
status: 1
|
||||
status: 0
|
||||
});
|
||||
|
||||
const result1 = runPrettier(
|
||||
|
@ -16,7 +16,7 @@ describe("output with --list-different + unformatted differs when piped", () =>
|
|||
["--write", "--list-different", "--no-color", "unformatted.js"],
|
||||
{ stdoutIsTTY: false }
|
||||
).test({
|
||||
status: 1
|
||||
status: 0
|
||||
});
|
||||
|
||||
expect(result0.stdout.length).toBeGreaterThan(result1.stdout.length);
|
||||
|
|
Loading…
Reference in New Issue