Skip to content

Instantly share code, notes, and snippets.

@lebbe
Last active August 7, 2023 09:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lebbe/b6e2558266707346214226c1eba8d8df to your computer and use it in GitHub Desktop.
Save lebbe/b6e2558266707346214226c1eba8d8df to your computer and use it in GitHub Desktop.
Automatically perform npm updates and make it a pull request
#!/bin/bash
# Update all minor and patch versions of your own dependencies, and thereafter
# update all transitive dependencies. Use the JIRA-number as first and only argument.
# Put this, for instance, in /usr/bin and make it executable:
#
# sudo mv npmu /usr/bin/npmu
# sudo chmod 744 /usr/bin/npmu
if [ $# -lt 1 ]; then
echo "$0: not enough arguments, try:"
echo "$0 [JIRA-#]"
exit 2
elif [ $# -gt 1 ]; then
echo "$0: too many arguments, try:"
echo "$0 [JIRA-#]"
exit 2
fi
git checkout master
git pull
git checkout -b "feature/$1-update-deps"
npm i -g npm-check-updates
ncu -t minor -u
rm package-lock.json
rm -rf node_modules
npm cache clear --force
npm install
git add .
git commit -m"$1 Update minor and patch version of all deps, and update all transitive deps."
git push --set-upstream origin "feature/$1-update-deps"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment