Skip to content

Instantly share code, notes, and snippets.

@mohammad19991
Last active April 25, 2018 11:26
Show Gist options
  • Save mohammad19991/61b6619c83d489a6ce9615f692cda251 to your computer and use it in GitHub Desktop.
Save mohammad19991/61b6619c83d489a6ce9615f692cda251 to your computer and use it in GitHub Desktop.
swiftlint script to check modified or added files in git.
#if [ "${CONFIGURATION}" = "Debug" ]; then
if which swiftlint >/dev/null; then
count=0
for file_path in $(git diff --diff-filter=ACM --name-only | grep ".*.swift$"); do
export SCRIPT_INPUT_FILE_$count=$file_path
count=$((count + 1))
done
for file_path in $(git diff --cached --name-only --diff-filter=ACM | grep ".*.swift$"); do
export SCRIPT_INPUT_FILE_$count=$file_path
count=$((count + 1))
done
export SCRIPT_INPUT_FILE_COUNT=$count
if (( $count > 0 )); then
swiftlint --config .swiftlint.yml --use-script-input-files
fi
else
echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi
#fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment