From 375663267b61a92335e9df3383936b72b4976844 Mon Sep 17 00:00:00 2001 From: Si Beaumont Date: Mon, 10 Jul 2023 08:50:20 +0100 Subject: [PATCH] Simplify swift-format soundness script --- Package.swift | 8 ++++---- scripts/run-swift-format.sh | 11 +++-------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/Package.swift b/Package.swift index bebbf51a..f59e57da 100644 --- a/Package.swift +++ b/Package.swift @@ -90,7 +90,7 @@ let package = Package( .testTarget( name: "OpenAPIGeneratorCoreTests", dependencies: [ - "_OpenAPIGeneratorCore", + "_OpenAPIGeneratorCore" ] ), @@ -103,7 +103,7 @@ let package = Package( .product(name: "SwiftFormatConfiguration", package: "swift-format"), ], resources: [ - .copy("Resources"), + .copy("Resources") ] ), @@ -113,7 +113,7 @@ let package = Package( .testTarget( name: "PetstoreConsumerTests", dependencies: [ - .product(name: "OpenAPIRuntime", package: "swift-openapi-runtime"), + .product(name: "OpenAPIRuntime", package: "swift-openapi-runtime") ] ), @@ -131,7 +131,7 @@ let package = Package( name: "OpenAPIGenerator", capability: .buildTool(), dependencies: [ - "swift-openapi-generator", + "swift-openapi-generator" ] ), ] diff --git a/scripts/run-swift-format.sh b/scripts/run-swift-format.sh index 4d72eeb0..36d3a26d 100644 --- a/scripts/run-swift-format.sh +++ b/scripts/run-swift-format.sh @@ -23,13 +23,8 @@ REPO_ROOT="$(git -C "${CURRENT_SCRIPT_DIR}" rev-parse --show-toplevel)" SWIFTFORMAT_BIN=${SWIFTFORMAT_BIN:-$(command -v swift-format)} || fatal "❌ SWIFTFORMAT_BIN unset and no swift-format on PATH" -"${SWIFTFORMAT_BIN}" lint \ - --parallel --recursive --strict \ - "${REPO_ROOT}/Examples" \ - "${REPO_ROOT}/IntegrationTest" \ - "${REPO_ROOT}/Plugins" \ - "${REPO_ROOT}/Sources" \ - "${REPO_ROOT}/Tests" \ +git -C "${REPO_ROOT}" ls-files -z '*.swift' \ + | xargs -0 "${SWIFTFORMAT_BIN}" lint --parallel --strict \ && SWIFT_FORMAT_RC=$? || SWIFT_FORMAT_RC=$? if [ "${SWIFT_FORMAT_RC}" -ne 0 ]; then @@ -37,7 +32,7 @@ if [ "${SWIFT_FORMAT_RC}" -ne 0 ]; then To fix, run the following command: - % swift-format format --parallel --recursive --in-place Examples IntegrationTest Plugins Sources Tests + % git ls-files -z '*.swift' | xargs -0 swift-format --in-place --parallel " exit "${SWIFT_FORMAT_RC}" fi