Skip to content

Commit d5399eb

Browse files
committed
Use swift format command provided by the Swift toolchain
As `swift-format` is included in recent Swift toolchains, we can rely on that instead of requiring `swift-format` to be preinstalled. Without this change the formatting script produces `swift-format not found in PATH` error, when `swift-format` is not redundantly installed outside of the Swift toolchain.
1 parent 7704862 commit d5399eb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Utilities/format.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func which(_ executable: String) -> URL? {
3838

3939
/// Runs the `swift-format` command with the given arguments in the project root.
4040
func swiftFormat(_ arguments: [String]) throws {
41-
guard let swiftFormat = which("swift-format") else {
41+
guard let swiftFormat = which("swift") else {
4242
print("swift-format not found in PATH")
4343
exit(1)
4444
}
@@ -93,7 +93,7 @@ switch arguments.first {
9393
case "lint":
9494
try swiftFormat(["lint", "--parallel", "--recursive"] + filesToFormat())
9595
case "format", nil:
96-
try swiftFormat(["format", "--parallel", "--in-place", "--recursive"] + filesToFormat())
96+
try swiftFormat(["format", "format", "--parallel", "--in-place", "--recursive"] + filesToFormat())
9797
case let subcommand?:
9898
print("Unknown subcommand: \(subcommand)")
9999
print("Usage: format.swift lint|format")

0 commit comments

Comments
 (0)