44 lines
1.0 KiB
TypeScript
44 lines
1.0 KiB
TypeScript
const colors = {
|
||
reset: '\x1b[0m',
|
||
bright: '\x1b[1m',
|
||
green: '\x1b[32m',
|
||
blue: '\x1b[34m',
|
||
yellow: '\x1b[33m',
|
||
red: '\x1b[31m',
|
||
cyan: '\x1b[36m'
|
||
} as const;
|
||
|
||
type Color = keyof typeof colors;
|
||
|
||
/** Prints a console message with the given ANSI colour. */
|
||
export function log(message: string, color: Color = 'reset'): void {
|
||
console.log(`${colors[color]}${message}${colors.reset}`);
|
||
}
|
||
|
||
/** Prints a success message (green). */
|
||
export function logSuccess(message: string): void {
|
||
log(`✅ ${message}`, 'green');
|
||
}
|
||
|
||
/** Prints an informational message (blue). */
|
||
export function logInfo(message: string): void {
|
||
log(`ℹ️ ${message}`, 'blue');
|
||
}
|
||
|
||
/** Prints a warning message (yellow). */
|
||
export function logWarning(message: string): void {
|
||
log(`⚠️ ${message}`, 'yellow');
|
||
}
|
||
|
||
/** Prints an error message (red). */
|
||
export function logError(message: string): void {
|
||
log(`❌ ${message}`, 'red');
|
||
}
|
||
|
||
/** Prints a step/stage header (cyan). */
|
||
export function logStep(message: string): void {
|
||
log(`\n🚀 ${message}`, 'cyan');
|
||
}
|
||
|
||
export { colors };
|