Created
June 25, 2021 11:56
-
-
Save earnubs/b4ddcbbd2493edbee4d96354145c575a to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
# | |
### | |
# Creates a stacked set of upgrade branches from outdated npm modules | |
# - use on major version upgrades (use `npm update` for minor) | |
### | |
set -e | |
git_stuff() { | |
if [[$3 =~ alpha|beta ]]; then | |
return 0 | |
fi | |
BRANCH="upgrade_$1_from_$2_to_$3" | |
echo $BRANCH | |
git checkout -b $BRANCH | |
npm i $1@$3 | |
git commit -am "Upgrade $1 from $2 to $3" --no-verify | |
git push --no-verify | |
} | |
export -f git_stuff | |
npm outdated --json | \ | |
jq -Mrc 'with_entries(.value = ({name: .key} + .value)) | .[] | "\(.name) \(.current) \(.latest)"' | \ | |
xargs -ptl bash -c 'git_stuff $0 $1 $2' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment