Skip to content

Commit

Permalink
update: Fix updating of npm globals
Browse files Browse the repository at this point in the history
There's a long trail here (from npm/npm#11534 to npm/cli#755) but basically, npm installs globals as if there were a caret given in the version, so that `npm upgrade -g` won't ever do anything beyond that semver.  Thus, we need to actually pass each individual package name to `npm install` (note: install, not upgrade) in order to actually update packages.
  • Loading branch information
Amorymeltzer committed Jun 2, 2020
1 parent 8dcb1ea commit 75d7454
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions bin/update
Expand Up @@ -144,15 +144,16 @@ fi

if [[ -z $npm_all_flag ]]; then
checking 'npm nodejs packages (global)'
# Means I miss out on the cool coloring in the output
npm_todo=$(npm outdated --global)
if [[ -n $npm_todo ]]; then
echo "$npm_todo"
if [[ -z $npm_flag ]]; then
updating 'npm nodejs packages (global)'
sudo npm upgrade --global;
# skip column headers, pass package names to npm install since
# global implies caret semver https://github.com/npm/cli/issues/746
echo "$npm_todo" | tail -n +2 | cut -f 1 -d ' ' | xargs npm install --global
fi
checking 'npm for unupdated packages FIXME TODO'
npm outdated --global
else
echo -e "${Color_Green}npm nodejs packages already up-to-date!${Color_zOff}"
fi
Expand Down

0 comments on commit 75d7454

Please sign in to comment.