mirror of
https://github.com/apple/pkl.git
synced 2026-05-25 16:19:20 +02:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 49e9117b85 | |||
| 5d6ff1f72a |
@@ -32,17 +32,15 @@ class CliFormatterApply(cliBaseOptions: CliBaseOptions, path: Path, private val
|
|||||||
val contents = Files.readString(path)
|
val contents = Files.readString(path)
|
||||||
val (formatted, stat) = format(path, contents)
|
val (formatted, stat) = format(path, contents)
|
||||||
status = if (status == 0) stat else status
|
status = if (status == 0) stat else status
|
||||||
if (stat != 0 || contents == formatted) continue
|
if (stat != 0) continue
|
||||||
if (!silent) {
|
if (!silent && contents != formatted) {
|
||||||
consoleWriter.write(path.toAbsolutePath().toString())
|
consoleWriter.write(path.toAbsolutePath().toString())
|
||||||
consoleWriter.appendLine()
|
|
||||||
consoleWriter.flush()
|
consoleWriter.flush()
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
path.writeText(formatted, Charsets.UTF_8)
|
path.writeText(formatted, Charsets.UTF_8)
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
consoleWriter.write("Could not overwrite `$path`: ${e.message}")
|
consoleWriter.write("Could not overwrite `$path`: ${e.message}")
|
||||||
consoleWriter.appendLine()
|
|
||||||
consoleWriter.flush()
|
consoleWriter.flush()
|
||||||
status = 1
|
status = 1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ class CliFormatterCheck(cliBaseOptions: CliBaseOptions, path: Path) :
|
|||||||
status = if (status == 0) stat else status
|
status = if (status == 0) stat else status
|
||||||
if (contents != formatted) {
|
if (contents != formatted) {
|
||||||
consoleWriter.write(path.toAbsolutePath().toString())
|
consoleWriter.write(path.toAbsolutePath().toString())
|
||||||
consoleWriter.appendLine()
|
|
||||||
consoleWriter.flush()
|
consoleWriter.flush()
|
||||||
status = 1
|
status = 1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ constructor(
|
|||||||
return Formatter().format(contents) to 0
|
return Formatter().format(contents) to 0
|
||||||
} catch (pe: GenericParserError) {
|
} catch (pe: GenericParserError) {
|
||||||
consoleWriter.write("Could not format `$file`: $pe")
|
consoleWriter.write("Could not format `$file`: $pe")
|
||||||
consoleWriter.appendLine()
|
|
||||||
consoleWriter.flush()
|
consoleWriter.flush()
|
||||||
return "" to 1
|
return "" to 1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,6 +66,6 @@ class FormatterApplyCommand : BaseCommand(name = "apply", helpLink = helpLink) {
|
|||||||
.flag()
|
.flag()
|
||||||
|
|
||||||
override fun run() {
|
override fun run() {
|
||||||
CliFormatterApply(baseOptions.baseOptions(emptyList()), path, silent).run()
|
CliFormatterApply(baseOptions.baseOptions(emptyList()), path, silent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
/// This file only contains a doc-comment
|
||||||
|
///
|
||||||
|
/// And nothing else
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
/// This file only contains a doc-comment
|
||||||
|
///
|
||||||
|
/// And nothing else
|
||||||
Reference in New Issue
Block a user