Skip to content

Instantly share code, notes, and snippets.

@nkt
Created May 31, 2015 21:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nkt/8bc77c9ed634f1294d3f to your computer and use it in GitHub Desktop.
Save nkt/8bc77c9ed634f1294d3f to your computer and use it in GitHub Desktop.
Frontend git hooks
#!/bin/sh
# List changed files
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_file() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
}
check_file "package.json" "npm install"
#!/bin/sh
npm run --silent reformat-css && npm run --silent lint-js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment