Skip to content

Commit b63982a

Browse files
committed
Add a bash script to simplify calling swift-syntax-dev-utils
Calling `swift-syntax-dev-utils` has always been a little bit cumbersome. Add a `swift-syntax-dev-utils` script that expands to `swift run --package-path SwiftSyntaxDevUtils/` to make it simpler. rdar://118137372 Fixes #2341
1 parent d647052 commit b63982a

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

CONTRIBUTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ swift-syntax is formatted using [swift-format](http://github.com/apple/swift-for
2323

2424
To format your changes run the formatter using the following command
2525
```bash
26-
swift run --package-path SwiftSyntaxDevUtils/ swift-syntax-dev-utils format
26+
./swift-syntax-dev-utils format
2727
```
2828
It will build a local copy of swift-format from the `main` branch and format the repository. Since it is building a release version of `swift-format`, the first run will take few minutes. Subsequent runs take less than 2 seconds.
2929

@@ -36,7 +36,7 @@ Generated source code is not formatted to make it easier to spot changes when re
3636
> #!/usr/bin/env bash
3737
> set -e
3838
> SOURCE_DIR=$(realpath "$(dirname $0)/../..")
39-
> swift run --package-path "$SOURCE_DIR/SwiftSyntaxDevUtils" swift-syntax-dev-utils format --lint
39+
> swift "$SOURCE_DIR/swift-syntax-dev-utils" format --lint
4040
> ```
4141
> 2. Mark the file as executable: `chmod a+x swift-syntax/.git/hooks/pre-commit`
4242
> 3. If you have global git hooks installed, be sure to call them at the end of the script with `path/to/global/hooks/pre-commit "$@"`

SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/commands/Format.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@ struct FormatExecutor {
8282
8383
Run the following command to format swift-syntax
8484
85-
swift run --package-path SwiftSyntaxDevUtils/ swift-syntax-dev-utils format
85+
./swift-syntax-dev-utils format
8686
8787
If the issue persists, try updating swift-format by running
8888
89-
swift run --package-path SwiftSyntaxDevUtils/ swift-syntax-dev-utils format --update
89+
./swift-syntax-dev-utils format --update
9090
9191
Should that still fail, fix any remaining issues manually and verify they match the swift-format style using
9292
93-
swift run --package-path SwiftSyntaxDevUtils/ swift-syntax-dev-utils format --lint
93+
./swift-syntax-dev-utils format --lint
9494
"""
9595
}
9696
}

swift-syntax-dev-utils

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env sh
2+
3+
swift run --package-path "$(dirname $0)/SwiftSyntaxDevUtils" swift-syntax-dev-utils "$@"

0 commit comments

Comments
 (0)