-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoutdated.js
More file actions
31 lines (28 loc) · 810 Bytes
/
outdated.js
File metadata and controls
31 lines (28 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//
// scan output of npm outdated
//
// exemple of json returned by npm outdated :
// =========================================
// {
// "express": {
// "current": "3.21.2",
// "wanted": "3.21.2",
// "latest": "4.17.1",
// "location": "node_modules/express"
// }
// }
var execFile = require('child_process').execFile;
module.exports = function (ac) {
execFile(/^win/.test(process.platform) ? 'npm.cmd' : 'npm', ['outdated', '--json'], function (err, stdout, stderr) {
// if (err) return ac(err);
if (stderr) return ac(new Error(stderr));
if (stdout == '') return ac();
var json = null;
try {
json = JSON.parse(stdout);
} catch (e) {
return ac(e);
}
ac(null, json);
});
};