From 215432fccd7bd2a02de50fa6533a4be6c6957871 Mon Sep 17 00:00:00 2001 From: Bentley Date: Tue, 25 Jul 2017 15:13:30 -0700 Subject: [PATCH] add quiet output --- lib/commands/check.js | 7 ++++++- lib/formatters/index.js | 1 + lib/formatters/quiet.js | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 lib/formatters/quiet.js diff --git a/lib/commands/check.js b/lib/commands/check.js index debd311..dcea110 100644 --- a/lib/commands/check.js +++ b/lib/commands/check.js @@ -53,7 +53,12 @@ module.exports = { name: 'warn-only', boolean: true, default: false - } + }, + { + name: 'quiet', + boolean: true, + default: false + } ], command: onCommand }; diff --git a/lib/formatters/index.js b/lib/formatters/index.js index de31594..bbce68a 100644 --- a/lib/formatters/index.js +++ b/lib/formatters/index.js @@ -5,5 +5,6 @@ module.exports = { default: require('./default'), summary: require('./summary'), json: require('./json'), + quiet: require('./quiet'), none: require('./none') }; diff --git a/lib/formatters/quiet.js b/lib/formatters/quiet.js new file mode 100644 index 0000000..c18554f --- /dev/null +++ b/lib/formatters/quiet.js @@ -0,0 +1,36 @@ +'use strict'; + +var Chalk = require('chalk'); +var Table = require('cli-table'); +var Cvss = require('cvss'); + +module.exports = function (err, data, pkgPath) { + + var returnString = ''; + + if (err) { + if (data) { + returnString += Chalk.red('(+) ') + 'Debug output: ' + JSON.stringify(Buffer.isBuffer(data) ? data.toString() : data) + '\n'; + } + + return returnString + Chalk.yellow('(+) ') + err; + } + + var width = 80; + var colWidth = 15; + if (process.stdout.isTTY) { + width = process.stdout.getWindowSize()[0] - 10; + if (!width || width <= colWidth) { + width = 80; + } + } + if (data.length === 0) { + + return ''; + } + + returnString += Chalk.red('(+) ') + data.length + ' vulnerabilities found\n'; + + + return returnString; +};