Created
September 2, 2016 15:25
-
-
Save hisabimbola/8323ab2f2a12dc0b54d29387ad94dcb2 to your computer and use it in GitHub Desktop.
Bulk update all npm modules of several repos
This file contains hidden or 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
#!/usr/bin/env zsh | |
if [[ -z "$1" ]] then | |
# Update to cd into the dir of your organization folder/dir | |
DIR=~/source | |
else | |
DIR="$1" | |
fi | |
CURRENT_DIR=`pwd` | |
cd "${DIR}" | |
for repo in `ls`; do | |
echo -e "\033[1mCurrently in $repo directory \033[0m" | |
cd "$repo" | |
if [[ -d .git ]] then | |
echo -e "\033[1mChecking out to master\033[0m" | |
gco master | |
echo -e "\033[1mFound git repository in $repo.\033[0m" | |
git pull | |
if [[ ! -z `git remote | grep upstream` ]] then | |
echo -e "\033[1mFetching upstream changes for $repo.\033[0m" | |
git fetch upstream | |
fi | |
echo -e "\033[1mRemoving all 'node_modules'\033[0m" | |
rm -rf /node_modules | |
echo -e "\033[1mRunning 'npm install'\033[0m" | |
npm i | |
fi | |
cd "${DIR}" | |
done | |
cd "${CURRENT_DIR}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment