mirror of
https://github.com/apple/pkl.git
synced 2026-03-21 00:29:07 +01:00
Fix bug in format apply (#1211)
This commit is contained in:
@@ -35,12 +35,14 @@ class CliFormatterApply(cliBaseOptions: CliBaseOptions, path: Path, private val
|
||||
if (stat != 0) continue
|
||||
if (!silent && contents != formatted) {
|
||||
consoleWriter.write(path.toAbsolutePath().toString())
|
||||
consoleWriter.appendLine()
|
||||
consoleWriter.flush()
|
||||
}
|
||||
try {
|
||||
path.writeText(formatted, Charsets.UTF_8)
|
||||
} catch (e: IOException) {
|
||||
consoleWriter.write("Could not overwrite `$path`: ${e.message}")
|
||||
consoleWriter.appendLine()
|
||||
consoleWriter.flush()
|
||||
status = 1
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ class CliFormatterCheck(cliBaseOptions: CliBaseOptions, path: Path) :
|
||||
status = if (status == 0) stat else status
|
||||
if (contents != formatted) {
|
||||
consoleWriter.write(path.toAbsolutePath().toString())
|
||||
consoleWriter.appendLine()
|
||||
consoleWriter.flush()
|
||||
status = 1
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ constructor(
|
||||
return Formatter().format(contents) to 0
|
||||
} catch (pe: GenericParserError) {
|
||||
consoleWriter.write("Could not format `$file`: $pe")
|
||||
consoleWriter.appendLine()
|
||||
consoleWriter.flush()
|
||||
return "" to 1
|
||||
}
|
||||
|
||||
@@ -66,6 +66,6 @@ class FormatterApplyCommand : BaseCommand(name = "apply", helpLink = helpLink) {
|
||||
.flag()
|
||||
|
||||
override fun run() {
|
||||
CliFormatterApply(baseOptions.baseOptions(emptyList()), path, silent)
|
||||
CliFormatterApply(baseOptions.baseOptions(emptyList()), path, silent).run()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user