#/usr/bin/env bash
# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
echo "$changed_files"


check_run() {
	havefile=`echo "$changed_files" | grep  "$1"`
	if [[ -n "${havefile}" ]];then
		eval "$2"
	fi
}

check_run package.json "npm install"
check_run bower.json "bower install --allow-root"