Skip to content

Instantly share code, notes, and snippets.

@aaronmccall
Last active August 29, 2015 14:07
Show Gist options
  • Save aaronmccall/6aee9510d8509c17c5ae to your computer and use it in GitHub Desktop.
Save aaronmccall/6aee9510d8509c17c5ae to your computer and use it in GitHub Desktop.
Script to see what top-level packages are outdated and then update them

Install

  1. Save the script below as update-outdated in your path.
  2. run chmod +x /path/to/update-outdated
  3. run update-outdated from the root of your project
  4. if you'd like to auto-update and save updated versions to your package.json, run again like so update-outdated -f
#! /bin/bash
for pkg in $(
npm outdated 2>&1 \
| grep -v http \
| grep -v Package \
| egrep -v '>' \
| sed -E "s/"$'\E'"\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K]//g" \
| awk '{ print $1 }' \
); do
if [ "$1" == "-f" ]; then
echo "updating $pkg to latest"
npm i "${pkg}@latest" --save &> /dev/null
else
echo "$pkg is out of date"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment