Last active
December 1, 2015 16:58
-
-
Save saintedlama/659098109235a96293fe to your computer and use it in GitHub Desktop.
Update all global node.js modules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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