forked from snyk/snyk-to-html
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
43 lines (38 loc) · 1022 Bytes
/
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
#!/usr/bin/env node
var fs = require('fs');
var snykToHtml = require('./lib/snyk-to-html.js');
var argv = require('minimist')(process.argv.slice(2));
var template, source, output;
if (argv.t) { // template
template = argv.t; // grab the next item
if (typeof template === 'boolean') {
template = __dirname + '/template/test-report.hbs';
}
} else {
template = __dirname + '/template/test-report.hbs';
}
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;
}
}
snykToHtml.run(source, template, onReportOutput);
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);
}
}