-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
27 lines (24 loc) · 1 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# install the swift formatters and pre-commit hook helper
install-formatters:
brew install swiftformat
brew install swift-format
npm install -g --save-dev git-format-staged
# Create and fill the pre-commit hook
precommit:
touch .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
echo '#!/bin/bash' > .git/hooks/pre-commit
echo '' >> .git/hooks/pre-commit
# echo 'git-format-staged --formatter "swift-format . -i -p --ignore-unparsable-files -r --configuration .swift-format '\''{}'\''" "*.swift"' >> .git/hooks/pre-commit
echo 'git-format-staged --formatter "swiftformat --config .swiftformat --swiftversion 5.7 stdin --stdinpath '\''{}'\''" "*.swift"' >> .git/hooks/pre-commit
# Setup the environment
start: install-formatters precommit
# Run the formatters manually
format:
# nicklockwood/SwiftFormat
swiftformat --config .swiftformat --swiftversion 5.7 .
# apple/swift-format
swift-format . -i -p --ignore-unparsable-files -r --configuration .swift-format
# commit
git add .
git commit -m "Format code"