Change pkl format --write to exit 0 when formatting violations are found (#1340)
This commit is contained in:
1 parent
2de1d5b9d2
commit
139f70bb79
2 files changed
+5
-3
No files matched your search
@@ -741,9 +741,9 @@ pkl shell-completion zsh
|
|||||||
This command formats or checks formatting of Pkl files. +
|
This command formats or checks formatting of Pkl files. +
|
||||||
Exit codes:
|
Exit codes:
|
||||||
|
|
||||||
* 0: No violations found.
|
* 0: No violations found or files were updated.
|
||||||
* 1: An unexpected error happened (ex.: IO error)
|
* 1: An unexpected error happened (ex.: IO error)
|
||||||
* 11: Violations were found.
|
* 11: Violations were found (when running without `--write`).
|
||||||
|
|
||||||
If the path is a directory, recursively looks for files with a `.pkl` extension, or files named `PklProject`.
|
If the path is a directory, recursively looks for files with a `.pkl` extension, or files named `PklProject`.
|
||||||
|
|
||||||
|
|||||||
@@ -110,7 +110,6 @@ constructor(
|
|||||||
|
|
||||||
val formatted = format(contents)
|
val formatted = format(contents)
|
||||||
if (contents != formatted) {
|
if (contents != formatted) {
|
||||||
status.update(FORMATTING_VIOLATION)
|
|
||||||
if (diffNameOnly || overwrite) {
|
if (diffNameOnly || overwrite) {
|
||||||
// if `--diff-name-only` or `-w` is specified, only write file names
|
// if `--diff-name-only` or `-w` is specified, only write file names
|
||||||
writeLine(pathStr)
|
writeLine(pathStr)
|
||||||
@@ -118,6 +117,9 @@ constructor(
|
|||||||
|
|
||||||
if (overwrite) {
|
if (overwrite) {
|
||||||
path.writeText(formatted, Charsets.UTF_8)
|
path.writeText(formatted, Charsets.UTF_8)
|
||||||
|
} else {
|
||||||
|
// only exit on violation for "check" operations, not when overwriting
|
||||||
|
status.update(FORMATTING_VIOLATION)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user