-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
Description
Describe the enhancement
After color output improvements (link and #583) I think it could be interesting to integrate to this toolkit, as an option disabled by default, color output for the following methods
toolkit/packages/core/src/core.ts
Lines 144 to 170 in 85f6235
| export function debug(message: string): void { | |
| issueCommand('debug', {}, message) | |
| } | |
| /** | |
| * Adds an error issue | |
| * @param message error issue message. Errors will be converted to string via toString() | |
| */ | |
| export function error(message: string | Error): void { | |
| issue('error', message instanceof Error ? message.toString() : message) | |
| } | |
| /** | |
| * Adds an warning issue | |
| * @param message warning issue message. Errors will be converted to string via toString() | |
| */ | |
| export function warning(message: string | Error): void { | |
| issue('warning', message instanceof Error ? message.toString() : message) | |
| } | |
| /** | |
| * Writes info to log with console.log. | |
| * @param message info message | |
| */ | |
| export function info(message: string): void { | |
| process.stdout.write(message + os.EOL) | |
| } |
Code Snippet
Current
toolkit/packages/core/src/command.ts
Lines 32 to 34 in 85f6235
| export function issue(name: string, message: string = ''): void { | |
| issueCommand(name, {}, message) | |
| } |
Change Proposal
import { red, yellow } from 'whatever-lib-to-color-output'
const logColors = {
error: red,
warning: yellow
}
...
function issue(name: string, message: string = '', useColoredMessage: boolean = false): void {
if(!useColoredMessage) issueCommand(name, {}, message)
else {
const paintMessage = logColors[name]
const paintedMessage = paintMessage? paintMessage(message) : message
issueCommand(name, {}, paintMessage(paintedMessage))
}
}Additional information
Here are some comparisons for some packages for coloring the output:
- https://www.npmtrends.com/colorette-vs-kleur-vs-chalk-vs-colors-vs-ansi-colors
- https://npmcompare.com/compare/ansi-colors,chalk,colorette,colors,kleur
In case this feature has sense, I guess it will need to be discussed how and which external package or internal utility to use.
PathogenDavid