Skip to content

Instantly share code, notes, and snippets.

@jaysalvat
Created February 17, 2017 16:03
Show Gist options
  • Save jaysalvat/7f81bf0bf0fcbc306a9a9d6104ad229a to your computer and use it in GitHub Desktop.
Save jaysalvat/7f81bf0bf0fcbc306a9a9d6104ad229a to your computer and use it in GitHub Desktop.
Check NPM for outdated dependencies and output a package.json friendly JSON.
'use strict';
let exec = require('child_process').exec;
exec('npm outdated --json', (err, stdout, sdterr) => {
if (!stdout) {
process.exit();
}
let json = JSON.parse(stdout),
keys = Object.keys(json),
output = {};
for (let k of keys) {
output[k] = '^' + json[k].latest;
}
console.log(JSON.stringify(output, null, 4));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment