Skip to content

Commit

Permalink
Merge pull request #502 from snyk/feat/colorful_docker_advice
Browse files Browse the repository at this point in the history
feat: allow passing color for docker cli response
  • Loading branch information
Tal Kaptsan committed May 23, 2019
2 parents 5ec5e3c + 165c29d commit 288165d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/cli/commands/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -579,17 +579,27 @@ function dockerRemediationForDisplay(res) {

if (advice) {
for (const item of advice) {
out.push(item.bold ? chalk.bold(item.message) : item.message);
out.push(getTerminalStringFormatter(item)(item.message));
}
} else if (message) {
out.push(message);
} else {
return '';
}

return `\n\n${out.join('\n')}`;
}

function getTerminalStringFormatter({ color, bold }) {
let formatter = chalk;
if (color && formatter[color]) {
formatter = formatter[color];
}
if (bold) {
formatter = formatter.bold;
}
return formatter;
}

function validateSeverityThreshold(severityThreshold) {
return SEVERITIES
.map((s) => s.verboseName)
Expand Down

0 comments on commit 288165d

Please sign in to comment.