Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const formatChange = (change: Change) => {
let color = (x: string): string => x;
if (change.severity === ChangeSeverity.FAILURE) {
color = chalk.red;
}
if (change.severity === ChangeSeverity.WARNING) {
color = chalk.yellow;
}
const changeDictionary: Record = {
[ChangeSeverity.FAILURE]: "FAIL",
[ChangeSeverity.WARNING]: "WARN",
[ChangeSeverity.NOTICE]: "PASS"
};
return {
severity: color(changeDictionary[change.severity]),
code: color(change.code),
description: color(change.description)
};
};