Created
September 22, 2015 12:06
-
-
Save tjunghans/1b7cde7c661ce9520d5d to your computer and use it in GitHub Desktop.
A node js script to show the latest version of the dependencies and devDependencies
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
"use strict"; | |
var shell = require("shelljs"); | |
var fs = require("fs"); | |
var pjson = JSON.parse(fs.readFileSync("./package.json"), "utf8"); | |
function printDependencies(deps) { | |
Object.keys(deps).forEach(function (name) { | |
console.log(name, deps[name].version + " --> " + deps[name].latest); | |
}); | |
} | |
function getDependencyVersions(deps, cb) { | |
var counter = 0; | |
var depsData = {}; | |
var keys = Object.keys(deps).sort(); | |
keys.forEach(function (key) { | |
shell.exec("npm show " + key + " version", {silent: true}, function (code, output) { | |
counter++; | |
depsData[key] = { | |
version: deps[key], | |
latest: output.trim() | |
}; | |
if (counter === keys.length) { | |
cb(depsData); | |
} | |
}); | |
}); | |
} | |
getDependencyVersions(pjson.dependencies, printDependencies); | |
getDependencyVersions(pjson.devDependencies, printDependencies); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment