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