Created
May 29, 2020 00:10
-
-
Save BronsonQuick/cf607d0714737d3919c73642fc9fac14 to your computer and use it in GitHub Desktop.
A gist that feeds diffs into a variable for precommit checks.
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
# Determine modified and staged files. | |
JSSTAGED=$(git --no-pager diff --relative --name-only --cached --diff-filter=d -- '**/*.js' \ | |
| xargs -L 1 printf "%s/%s\n" "$PWD") | |
PHPSTAGED=$(git --no-pager diff --relative --name-only --cached --diff-filter=d -- '**/*.php' \ | |
| xargs -L 1 printf "%s/%s\n" "$PWD") | |
CSSSTAGED=$(git --no-pager diff --relative --name-only --cached --diff-filter=d -- '**/*.css' \ | |
| xargs -L 1 printf "%s/%s\n" "$PWD") | |
SCSSSTAGED=$(git --no-pager diff --relative --name-only --cached --diff-filter=d -- '**/*.scss' \ | |
| xargs -L 1 printf "%s/%s\n" "$PWD") | |
TSSTAGED=$(git --no-pager diff --relative --name-only --cached --diff-filter=d -- '**/*.ts' '**/*.tsx' \ | |
| xargs -L 1 printf "%s/%s\n" "$PWD") | |
Then feed the vars into the sniffers: | |
if [ ! -z "$JSSTAGED" ]; then | |
yarn --cwd $(git rev-parse --show-toplevel)/src eslint $JSSTAGED | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment