Created
January 23, 2018 16:05
-
-
Save alexmiranda/f5377ce4068c35373f59080633d46b4f to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/sh | |
DIRECTORY="./node_modules" | |
if [ ! -d "$DIRECTORY" ]; then | |
# if package.json exists in the root folder, inform the user to do 'npm install' | |
if [ -f "./package.json" ]; then | |
echo "Cannot find node_modules folder, please run 'npm install' first" | |
exit -1 | |
fi | |
# search for the first package.json file in the project structure | |
SEARCH=`find . -name 'node_modules' -type d -prune -o -name package.json -type f -print -quit` | |
if [ ! -z "$SEARCH" -a "$SEARCH" != "" ]; then | |
DIRECTORY="$(dirname $SEARCH)/node_modules" | |
if [ ! -d "$DIRECTORY" ]; then | |
echo "Cannot find node_modules folder, please run 'npm install' first" | |
exit -1 | |
fi | |
else | |
# package.json not found - user might've deleted it after installing pre-git | |
echo "Cannot find package.json file" | |
exit -1 | |
fi | |
fi | |
if [ ! -x "$(command -v node)" ]; then | |
echo "Node binary not found, please ensure it has been properly installed" | |
exit -1 | |
fi | |
"$DIRECTORY/.bin/pre-push" "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment