To update all packages that are returned by the npm outdated
command to their latest version:
$ npm outdated | tail -n +2 | tr -s ' ' | cut -d ' ' -f1 | xargs -I {} npm up {}
npm outdated
: Lists all packages installed that are not at their latest version.
tail -n +2
: start parsing the output of the previous command from the seccond line (cut off the headers from npm outdated
)
tf -s ''
: since there are varying amounts of whitespace between some of the columns, squeeze it down to just one space between each column
cut -d ' ' -f1
: split the previous output into columns on the "space" character and then print the first field
xargs -I {} npm up {}
: run the npm up
command for each line of the output and replace {}
with the actual output (in this case the package name)