Created
June 3, 2021 09:14
-
-
Save smit9612/02f0c9961ffdcf63c29dd610840c239f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
git diff --cached --name-only | grep "\.swift" | while read filename; do | |
if which swiftlint >/dev/null; then | |
swiftlint lint --path "$filename"; | |
else | |
echo "warning: SwiftLint not installed, download from https://github.com/ realm/SwiftLint" | |
fi | |
done | |
git-format-staged --formatter "swiftformat stdin --stdinpath '{}'" "*.swift" |
Author
smit9612
commented
Jun 3, 2021
•
- /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
- brew install swiftformat
- brew install swiftlint
- npm install --save-dev git-format-staged
- copy above gist in .git/hooks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment