ensure --list-different + --write reports status code 0 (#5512)

* change exit code for list different and write

* update existing tests
This commit is contained in:
evelyn masso authored and Jed Fox committed 2018-11-23 10:42:29 -05:00
1 parent 7da4ed76ad
commit e12cd17be2
3 files changed
+7 -5

No files matched your search

+4 -2
View File
@@ -146,8 +146,8 @@ function listDifferent(context, input, options, filename) {
if (!prettier.check(input, options)) {
if (!context.argv["write"]) {
context.logger.log(filename);
process.exitCode = 1;
}
process.exitCode = 1;
}
} catch (error) {
context.logger.error(error.message);
@@ -498,7 +498,9 @@ function formatFiles(context) {
if (context.argv["list-different"] && isDifferent) {
context.logger.log(filename);
process.exitCode = 1;
if (!context.argv["write"]) {
process.exitCode = 1;
}
}
if (context.argv["write"]) {
+1 -1
View File
@@ -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 }
);
});
});
+2 -2
View File
@@ -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);