Last active
August 29, 2015 13:57
-
-
Save aaronmccall/9897398 to your computer and use it in GitHub Desktop.
bash script to npm i --save-exact an npm package/module in every repo in a directory
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 | |
if [ $# -lt 2 ]; then | |
echo "Usage: update_package <directory> <package> [optional: <version>]" | |
exit 1 | |
fi | |
if [ "$3" ]; then | |
version=$3 | |
else | |
version="latest" | |
fi | |
echo "looking for: /^\s+\"${2}\":/ in package.json" | |
for arg in $( ls $1 | egrep '^dsm-' ); do | |
( | |
cd "$arg" | |
if egrep -q "\"${2}\":" package.json; then | |
echo "$arg has $2" | |
echo "running: npm i $2@$version --save-exact" | |
npm i "$2@$version" --save-exact | |
fi | |
) | |
done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment