-
Notifications
You must be signed in to change notification settings - Fork 29
/
index.js
executable file
·53 lines (45 loc) · 1.14 KB
/
index.js
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
45
46
47
48
49
50
51
52
53
#!/usr/bin/env node
var debug = require('debug')('index')
var fs = require('fs');
var snykFilter = require('./lib/snyk-filter.js');
var argv = require('minimist')(process.argv.slice(2));
var os = require('os');
var path = require('path');
var template, source, output;
var options = {};
if (argv.i) { // input source
source = argv.i; // grab the next item
if (typeof source === 'boolean') {
source = undefined;
}
}
if (argv.o) { // output destination
output = argv.o; // grab the next item
if (typeof output === 'boolean') {
output = undefined;
}
}
if (argv.json) { // output destination
options = {"json": true};
}
if (argv.f) { // output destination
filters = argv.f;
if (typeof output === 'boolean') {
output = undefined;
}
} else {
filters = path.join(process.cwd(), "/.snyk-filter/snyk.yml");
}
snykFilter.run(source, onReportOutput, filters, options);
function onReportOutput(report) {
if (output) {
fs.writeFile(output, report, function (err) {
if (err) {
return console.log(err);
}
console.log('Vulnerability snapshot saved at ' + output);
});
} else {
console.log(report);
}
}