diff --git a/.gitignore b/.gitignore index 982ee3ca..1f05dc75 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ DerivedData/ # Other things to ignore: /node_modules +/.swiftformat-cache diff --git a/script/format/check b/script/format/check index bcdfb4e1..8e4dee25 100755 --- a/script/format/check +++ b/script/format/check @@ -2,5 +2,7 @@ set -e -swift package plugin --allow-writing-to-package-directory swiftformat --lint +# Without specifying --cache we get a warning of "Failed to write cache file at /Users/lawrence/Library/Caches/com.charcoaldesign.swiftformat/swiftformat.cache."; presumably this is to do with sandboxing restrictions imposed on Swift package scripts. +swift package plugin --allow-writing-to-package-directory swiftformat --cache .swiftformat-cache --lint + npm run format:check diff --git a/script/format/fix b/script/format/fix index a54cb1b5..d0a3f06f 100755 --- a/script/format/fix +++ b/script/format/fix @@ -2,5 +2,7 @@ set -e -swift package plugin --allow-writing-to-package-directory swiftformat +# (See the `check` script for why we specify --cache. The repetition is because, according to https://github.com/nicklockwood/SwiftFormat/issues/1651#issuecomment-2009943414, you can’t use a .swiftformat file to specify the --cache option.) +swift package plugin --allow-writing-to-package-directory swiftformat --cache .swiftformat-cache + npm run format:fix