Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update formatting script #1845

Merged
merged 2 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions Plugins/GRPCSwiftPlugin/plugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ struct GRPCSwiftPlugin {
return "The input file '\(path)' does not have a '.proto' extension."
case let .noConfigFound(path):
return """
No configuration file found named '\(path)'. The file must not be listed in the \
'exclude:' argument for the target in Package.swift.
"""
No configuration file found named '\(path)'. The file must not be listed in the \
'exclude:' argument for the target in Package.swift.
"""
}
}
}
Expand Down Expand Up @@ -99,11 +99,13 @@ struct GRPCSwiftPlugin {
sourceFiles: FileList,
tool: (String) throws -> PackagePlugin.PluginContext.Tool
) throws -> [Command] {
guard let configurationFilePath = sourceFiles.first(
where: {
$0.path.lastComponent == Self.configurationFileName
}
)?.path else {
guard
let configurationFilePath = sourceFiles.first(
where: {
$0.path.lastComponent == Self.configurationFileName
}
)?.path
else {
throw PluginError.noConfigFound(Self.configurationFileName)
}

Expand Down
10 changes: 7 additions & 3 deletions scripts/format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ THIS_SCRIPT=$0
HERE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
REPO="$HERE/.."
SWIFTFORMAT_DIR="$HERE/.swift-format-source"
SWIFTFORMAT_VERSION=509.0.0
SWIFTFORMAT_VERSION=510.0.0

# Clone SwiftFormat if we don't already have it.
if [ ! -d "$SWIFTFORMAT_DIR" ]; then
Expand Down Expand Up @@ -91,7 +91,9 @@ fi
if "$lint"; then
"${SWIFTFORMAT_BIN}" lint \
--parallel --recursive --strict \
"${REPO}/Sources" "${REPO}/Tests" \
"${REPO}/Sources" \
"${REPO}/Tests" \
"${REPO}/Plugins" \
&& SWIFT_FORMAT_RC=$? || SWIFT_FORMAT_RC=$?

if [[ "${SWIFT_FORMAT_RC}" -ne 0 ]]; then
Expand All @@ -108,7 +110,9 @@ if "$lint"; then
elif "$format"; then
"${SWIFTFORMAT_BIN}" format \
--parallel --recursive --in-place \
"${REPO}/Sources" "${REPO}/Tests" \
"${REPO}/Sources" \
"${REPO}/Tests" \
"${REPO}/Plugins" \
&& SWIFT_FORMAT_RC=$? || SWIFT_FORMAT_RC=$?

if [[ "${SWIFT_FORMAT_RC}" -ne 0 ]]; then
Expand Down
Loading