Skip to content

Instantly share code, notes, and snippets.

@hisabimbola
Created September 2, 2016 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hisabimbola/8323ab2f2a12dc0b54d29387ad94dcb2 to your computer and use it in GitHub Desktop.
Save hisabimbola/8323ab2f2a12dc0b54d29387ad94dcb2 to your computer and use it in GitHub Desktop.
Bulk update all npm modules of several repos
#!/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