-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
detail: Switch to inverting the cmd to run instead of quoting
The idea here is that this way double clicking the command to run will never pick up backticks. It's also substantially more visible. I swapped from `ansicolors` to my own `console-control-strings` for this to get the invert codes.
- Loading branch information
Showing
5 changed files
with
25 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,26 @@ | ||
'use strict' | ||
exports.severityLabel = severityLabel | ||
exports.color = color | ||
|
||
const colors = require('ansicolors') | ||
const ccs = require('console-control-strings') | ||
|
||
const severityColors = { | ||
critical: colors.magenta, | ||
high: colors.red, | ||
moderate: colors.yellow, | ||
low: function (str) { return str } | ||
function color (name) { | ||
const start = ccs.color(name) | ||
const stop = ccs.color(reset) | ||
return str => start + str + stop | ||
} | ||
|
||
const severityLabel = function (sev, withColor) { | ||
if (withColor) { | ||
return severityColors[sev](sev) | ||
} | ||
return sev | ||
const severityColors = { | ||
critical: 'magenta', | ||
high: 'red', | ||
moderate: 'yellow', | ||
low: null | ||
} | ||
|
||
const color = function (value, color, withColor) { | ||
if (withColor) { | ||
return colors[color](value) | ||
} | ||
return value | ||
function color (value, colorName, withColor) { | ||
return (colorName && withColor) ? ccs.color(colorName) + value + ccs.color('reset') : value | ||
} | ||
|
||
module.exports = { | ||
severityLabel: severityLabel, | ||
color: color | ||
function severityLabel (sev, withColor) { | ||
return color(sev, severityColors[sev], withColor) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters