From 42bdb19dad0835867da3399bf06ff6e547554390 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 25 Sep 2023 00:56:46 -0700 Subject: [PATCH] feat: initial support for Swift Plugins (#556) Co-authored-by: Valentin Kiselev --- Makefile | 3 ++- docs/install.md | 9 +++++++++ internal/templates/hook.tmpl | 3 +++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index cd044ada..0b15e3f9 100644 --- a/Makefile +++ b/Makefile @@ -30,5 +30,6 @@ version: @read -p "New version: " version sed -i "s/const version = .*/const version = \"$$version\"/" internal/version/version.go sed -i "s/VERSION := .*/VERSION := $$version/" packaging/Makefile + sed -i "s/lefthook-plugin.git\", exact: \".*\"/lefthook-plugin.git\", exact: \"$$version\"/" docs/install.md make -C packaging clean set-version - git add internal/version/version.go packaging/* + git add internal/version/version.go packaging/* docs/install.md diff --git a/docs/install.md b/docs/install.md index 2090dc42..c880701f 100644 --- a/docs/install.md +++ b/docs/install.md @@ -6,6 +6,7 @@ Choose your fighter: - [Node.js](#node) - [Go](#go) - [Python](#python) +- [Swift](#swift) - [Scoop](#scoop) - [Homebrew](#homebrew) - [Winget](#winget) @@ -70,6 +71,14 @@ You can find Python wrapper here [package](https://github.com/life4/lefthook) python3 -m pip install --user lefthook ``` +## Swift + +You can find the Swift wrapper plugin [here](https://github.com/csjones/lefthook-plugin). To utilize lefthook, include the plugin in the dependencies section of your `Package.swift`: + +```swift +.package(url: "https://github.com/csjones/lefthook-plugin.git", exact: "1.5.0"), +``` + ## Scoop for Windowss ```sh diff --git a/internal/templates/hook.tmpl b/internal/templates/hook.tmpl index af750cd5..74b45034 100644 --- a/internal/templates/hook.tmpl +++ b/internal/templates/hook.tmpl @@ -46,6 +46,9 @@ call_lefthook() elif command -v npx >/dev/null 2>&1 then npx @evilmartians/lefthook "$@" + elif swift package plugin lefthook >/dev/null 2>&1 + then + swift package --disable-sandbox plugin lefthook $@ else echo "Can't find lefthook in PATH" {{- if .AssertLefthookInstalled}}