Skip to content

Commit

Permalink
Add "--write" to the prettier failure output (prettier#16062)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdentremont committed Feb 14, 2024
1 parent f4b3b7b commit 4aebc0e
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Console output if some of the files require re-formatting:
Checking formatting...
[warn] src/fileA.js
[warn] src/fileB.js
[warn] Code style issues found in 2 files. Run Prettier to fix.
[warn] Code style issues found in 2 files. Run Prettier with --write to fix.
```

The command will return exit code `1` in the second case, which is helpful inside the CI pipelines.
Expand Down
2 changes: 1 addition & 1 deletion src/cli/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ async function formatFiles(context) {
context.logger.warn(
context.argv.write
? `Code style issues fixed in ${files}.`
: `Code style issues found in ${files}. Run Prettier to fix.`,
: `Code style issues found in ${files}. Run Prettier with --write to fix.`,
);
}
}
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/__tests__/__snapshots__/check.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`--checks should print the number of files that need formatting (stderr) 1`] = `
"[warn] unformatted.js
[warn] unformatted2.js
[warn] Code style issues found in 2 files. Run Prettier to fix."
[warn] Code style issues found in 2 files. Run Prettier with --write to fix."
`;

exports[`--checks should print the number of files that need formatting (stdout) 1`] = `"Checking formatting..."`;
Expand All @@ -12,12 +12,12 @@ exports[`--checks should print the number of files that need formatting (write)

exports[`--checks works in CI just as in a non-TTY mode (stderr) 1`] = `
"[warn] unformatted.js
[warn] Code style issues found in the above file. Run Prettier to fix."
[warn] Code style issues found in the above file. Run Prettier with --write to fix."
`;

exports[`--checks works in CI just as in a non-TTY mode (stderr) 2`] = `
"[warn] unformatted.js
[warn] Code style issues found in the above file. Run Prettier to fix."
[warn] Code style issues found in the above file. Run Prettier with --write to fix."
`;

exports[`--checks works in CI just as in a non-TTY mode (stdout) 1`] = `"Checking formatting..."`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ override.as-js-file"
exports[`ignore-unknown check (stderr) 1`] = `
"[warn] javascript.js
[warn] override.as-js-file
[warn] Code style issues found in 2 files. Run Prettier to fix."
[warn] Code style issues found in 2 files. Run Prettier with --write to fix."
`;

exports[`ignore-unknown check (stdout) 1`] = `"Checking formatting..."`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`--check with unknown path and no parser multiple files (stderr) 1`] = `
"[error] No parser could be inferred for file "<cli>/infer-parser/FOO".
[warn] foo.js
[warn] Code style issues found in the above file. Run Prettier to fix."
[warn] Code style issues found in the above file. Run Prettier with --write to fix."
`;
exports[`--check with unknown path and no parser multiple files (stdout) 1`] = `"Checking formatting..."`;
Expand Down
2 changes: 1 addition & 1 deletion website/blog/2023-07-05-3.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -2060,7 +2060,7 @@ UndefinedParserError: No parser and no file path given, couldn't infer a parser.

#### Updated failure message to be more informative ([#11369](https://github.com/prettier/prettier/pull/11369) by [@webark](https://github.com/webark))

Updated the "Forgot to run Prettier?" to "Run Prettier to fix."
Updated the "Forgot to run Prettier?" to "Run Prettier with --write to fix."

This keeps the same spirit of the message, but is less likely to be
misinterpreted as it's a more formal message rather than being
Expand Down
2 changes: 1 addition & 1 deletion website/versioned_docs/version-stable/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Console output if some of the files require re-formatting:
Checking formatting...
[warn] src/fileA.js
[warn] src/fileB.js
[warn] Code style issues found in 2 files. Run Prettier to fix.
[warn] Code style issues found in 2 files. Run Prettier with --write to fix.
```

The command will return exit code `1` in the second case, which is helpful inside the CI pipelines.
Expand Down

0 comments on commit 4aebc0e

Please sign in to comment.