Last active
January 18, 2016 11:02
-
-
Save ewnd9/036f840399986653eed5 to your computer and use it in GitHub Desktop.
Prevent executing "npm install <deps>" without `-S`, `-D`, `--save`, `--save-dev`, `-g` flags
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/bash | |
set -e | |
if ([ "$1" == "install" ] || [ "$1" == "i" ]) && [ "$#" -ne 1 ]; then | |
for var in "$@" | |
do | |
if [ "$var" == "--save" ] || [ "$var" == "--save-dev" ] || [ "$var" == "-S" ] || [ "$var" == "-D" ] || [ "$var" == "-g" ]; then | |
has_modifier=true | |
fi | |
done | |
if [ "$has_modifier" != true ]; then | |
echo "npm install without --save or --save-dev" | |
exit 1 | |
fi | |
fi | |
npm $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment