summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/npm-audit-report/lib/utils.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/npm-audit-report/lib/utils.js')
-rw-r--r--deps/npm/node_modules/npm-audit-report/lib/utils.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/deps/npm/node_modules/npm-audit-report/lib/utils.js b/deps/npm/node_modules/npm-audit-report/lib/utils.js
new file mode 100644
index 0000000000..069ebac8a0
--- /dev/null
+++ b/deps/npm/node_modules/npm-audit-report/lib/utils.js
@@ -0,0 +1,35 @@
+'use strict'
+
+exports.severityLabel = severityLabel
+exports.color = color
+
+const ccs = require('console-control-strings')
+
+const severityColors = {
+ critical: {
+ color: 'brightMagenta',
+ label: 'Critical'
+ },
+ high: {
+ color: 'brightRed',
+ label: 'High'
+ },
+ moderate: {
+ color: 'brightYellow',
+ label: 'Moderate'
+ },
+ low: {
+ color: 'bold',
+ label: 'Low'
+ }
+}
+
+function color (value, colorName, withColor) {
+ return (colorName && withColor) ? ccs.color(colorName) + value + ccs.color('reset') : value
+}
+
+function severityLabel (sev, withColor, bold) {
+ let colorName = severityColors[sev].color
+ if (bold) colorName = [colorName, 'bold']
+ return color(severityColors[sev].label, colorName, withColor)
+}