From 6c1be261c1f31f140ac7c8306a98c2346d26408d Mon Sep 17 00:00:00 2001 From: Lawrence Forooghian Date: Thu, 1 Aug 2024 09:57:00 +0100 Subject: [PATCH] fix SwiftFormat caching --- .gitignore | 1 + script/format/check | 4 +++- script/format/fix | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) 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