Skip to content

Instantly share code, notes, and snippets.

@PatrickHeneise
Last active November 21, 2018 08:59
Show Gist options
  • Save PatrickHeneise/c008146661ebfa5ede499086252a2372 to your computer and use it in GitHub Desktop.
Save PatrickHeneise/c008146661ebfa5ede499086252a2372 to your computer and use it in GitHub Desktop.
Update all packages in subfolders
#!/bin/bash
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
for i in * ; do
if [ -d "$i" ]; then
cd "$i"
printf '\n\n%s\n' "${PWD##*/}$(parse_git_branch):"
if [ -f package.json ]; then
git checkout package-lock.json
git checkout -B chore/package-updates
npm i -D updates -u --semver minor && npm audit fix && npm test && git commit package.json package-lock.json -m 'chore: pacakge updates' && git push
git checkout master
fi
cd ..
fi
done
@PatrickHeneise
Copy link
Author

Works great in a Makefile for projects with multiple repos:

/Makefile
/bin/upgrade.sh
/web
/api
/app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment