Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- function addFilesToLint {
- filename=""
- count=$2
- for item in $1
- do
- if [[ $item == *".swift"* ]]; then
- filename+="$item"
- export SCRIPT_INPUT_FILE_$count="$filename"
- count=$((count + 1))
- filename=""
- else
- filename+="$item "
- fi
- done
- }
- count=0
- #grep returns result as array divided by newline
- targets=$(git ls-files -om --exclude-from=.gitignore | grep -F ".swift")
- addFilesToLint "${targets[0]}" $count
- targets=$(git diff --cached --name-only | grep -F ".swift$")
- addFilesToLint "${targets[0]}" $count
- export -p | grep SCRIPT_INPUT_FILE
- export SCRIPT_INPUT_FILE_COUNT=$count
- swiftlint lint --use-script-input-files
- exit 0
Add Comment
Please, Sign In to add comment