-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjsinspect.js
More file actions
44 lines (42 loc) · 1.91 KB
/
jsinspect.js
File metadata and controls
44 lines (42 loc) · 1.91 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
// [
// {
// "id": "2550ba437078eb6a5b2d25d3916a9d0d273dbf90",
// "instances": [
// {
// "path": "../audit.js",
// "lines": [
// 87,
// 98
// ],
// "code": " execFile(/^win/.test(process.platform) ? 'npm.cmd' : 'npm', ['audit', '--json'], function(err, stdout, stderr) {\n // if (err) return ac(err);\n if (stderr) return ac(new Error(stderr));\nif (stdout == '') return ac()\n var json = null;\n try{\n json = JSON.parse(stdout);\n } catch(e) {\n return ac(e);\n }\n ac(null, json);\n });"
// },
// {
// "path": "../outdated.js",
// "lines": [
// 18,
// 30
// ],
// "code": "execFile(/^win/.test(process.platform) ? 'npm.cmd' : 'npm', ['outdated', '--json'], function(err, stdout, stderr) {\n // if (err) return ac(err);\n if (stderr) return ac(new Error(stderr));\n if (stdout == '') return ac()\n\n var json = null;\n try{\n json = JSON.parse(stdout);\n } catch(e) {\n return ac(e);\n }\n ac(null, json);\n});"
// }
// ]
// },
// ]
var execFile = require('child_process').execFile;
module.exports = function (dir, ac) {
execFile(
/^win/.test(process.platform) ? 'npx.cmd' : 'npx',
['-q', 'jsinspect', '--reporter', 'json', '--ignore', 'web/|doc/', dir],
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);
}
);
};