Skip to content

Instantly share code, notes, and snippets.

@saintedlama
Last active December 1, 2015 16:58
Show Gist options
  • Save saintedlama/659098109235a96293fe to your computer and use it in GitHub Desktop.
Save saintedlama/659098109235a96293fe to your computer and use it in GitHub Desktop.
Update all global node.js modules
require('shelljs/global');
var execOutdated = exec('npm outdated -g --depth=0 --json');
if (execOutdated.code != 0) {
console.log(execOutdated.output);
process.exit(1);
}
if (execOutdated.output == '') {
console.log('Everything is up to date! Awesome!');
process.exit(0);
}
var outdatedModules = JSON.parse(execOutdated.output);
for (var m in outdatedModules) {
if (outdatedModules.hasOwnProperty(m)) {
exec('npm install ' + m + ' -g');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment