Skip to content

Instantly share code, notes, and snippets.

@FredLackeyOfficial
Created March 14, 2017 20:39
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 FredLackeyOfficial/47b732f3380a7ba2a217ff135bde6366 to your computer and use it in GitHub Desktop.
Save FredLackeyOfficial/47b732f3380a7ba2a217ff135bde6366 to your computer and use it in GitHub Desktop.
Use npm-check-updates recursively to update Node modules and Bower components.
cmd_exists() {
command -v "$1" &> /dev/null
}
ncu-update-all(){
if ! cmd_exists "ncu"; then
printf "ncu is required, please install it!\n"
exit 1
fi
for file in $(find . -type f -name "package.json" -not \( -path "*/node_modules/*" \) -not \( -path "*/bower_components/*" \)); do
if [ -f "$file" ]; then
eval "ncu -a -u --packageFile $file"
fi
done
for file in $(find . -type f -name "bower.json" -not \( -path "*/node_modules/*" \) -not \( -path "*/bower_components/*" \)); do
if [ -f "$file" ]; then
eval "ncu -a -u -m bower --packageFile $file"
fi
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment