Skip to content

Instantly share code, notes, and snippets.

@guychouk
Last active January 26, 2021 13:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guychouk/66db19badad9509b6edd0062fa35766a to your computer and use it in GitHub Desktop.
Save guychouk/66db19badad9509b6edd0062fa35766a to your computer and use it in GitHub Desktop.
Post merge/pull hook to run npm command only if view files changed
#!/bin/bash
changedFiles="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
runOnChange() {
echo "$changedFiles" | grep -q "$1" && eval "$2"
}
runOnChange resources/js/ "npm run <your-npm-script>"
runOnChange resources/scss/ "npm run <your-npm-script>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment