-
-
Save nanoxd/d9d63caa9c95eb8292ed8273a0bd314e to your computer and use it in GitHub Desktop.
[bin/lint] Binary to run swiftlint, meant to be placed at the root of the project #sh
This file contains hidden or 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/sh | |
# | |
# Lint any changed files using swiftlint. | |
# | |
# This works both independently and as a run phase script. | |
# Path to installed version of Swift lint. | |
readonly SWIFT_LINT_PATH=$(which swiftlint) | |
if [ -z "$SWIFT_LINT_PATH" ]; then | |
echo "warning: SwiftLint not installed. Run 'brew bundle' to ensure its installation." | |
exit 0 | |
fi | |
_lint() { | |
local filename="${1}" | |
if [[ "${filename##*.}" == "swift" ]]; then | |
${SWIFT_LINT_PATH} lint --path "${filename}" | |
fi | |
} | |
git diff --cached --name-only | while read filename; do _lint "${filename}"; done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment