@@ -11,10 +11,9 @@ import { JsonValue, logging, schema } from '@angular-devkit/core';
1111import { ProcessOutput , createConsoleLogger } from '@angular-devkit/core/node' ;
1212import { UnsuccessfulWorkflowExecution , strings } from '@angular-devkit/schematics' ;
1313import { NodeWorkflow } from '@angular-devkit/schematics/tools' ;
14- import ansiColors from 'ansi-colors' ;
1514import { existsSync } from 'node:fs' ;
1615import * as path from 'node:path' ;
17- import { parseArgs } from 'node:util' ;
16+ import { parseArgs , styleText } from 'node:util' ;
1817
1918/**
2019 * Parse the name of schematic passed in argument, and return a {collection, schematic} named
@@ -223,16 +222,13 @@ export async function main({
223222} : MainOptions ) : Promise < 0 | 1 > {
224223 const { cliOptions, schematicOptions, _ } = parseOptions ( args ) ;
225224
226- // Create a separate instance to prevent unintended global changes to the color configuration
227- const colors = ansiColors . create ( ) ;
228-
229225 /** Create the DevKit Logger used through the CLI. */
230226 const logger = createConsoleLogger ( ! ! cliOptions . verbose , stdout , stderr , {
231227 info : ( s ) => s ,
232228 debug : ( s ) => s ,
233- warn : ( s ) => colors . bold . yellow ( s ) ,
234- error : ( s ) => colors . bold . red ( s ) ,
235- fatal : ( s ) => colors . bold . red ( s ) ,
229+ warn : ( s ) => styleText ( [ ' bold' , ' yellow' ] , s ) ,
230+ error : ( s ) => styleText ( [ ' bold' , ' red' ] , s ) ,
231+ fatal : ( s ) => styleText ( [ ' bold' , ' red' ] , s ) ,
236232 } ) ;
237233
238234 if ( cliOptions . help ) {
@@ -315,21 +311,21 @@ export async function main({
315311 case 'update' :
316312 loggingQueue . push (
317313 // TODO: `as unknown` was necessary during TS 5.9 update. Figure out a long-term solution.
318- `${ colors . cyan ( 'UPDATE' ) } ${ eventPath } (${ ( event . content as unknown as Buffer ) . length } bytes)` ,
314+ `${ styleText ( [ 'cyan' ] , 'UPDATE' ) } ${ eventPath } (${ ( event . content as unknown as Buffer ) . length } bytes)` ,
319315 ) ;
320316 break ;
321317 case 'create' :
322318 loggingQueue . push (
323319 // TODO: `as unknown` was necessary during TS 5.9 update. Figure out a long-term solution.
324- `${ colors . green ( 'CREATE' ) } ${ eventPath } (${ ( event . content as unknown as Buffer ) . length } bytes)` ,
320+ `${ styleText ( [ 'green' ] , 'CREATE' ) } ${ eventPath } (${ ( event . content as unknown as Buffer ) . length } bytes)` ,
325321 ) ;
326322 break ;
327323 case 'delete' :
328- loggingQueue . push ( `${ colors . yellow ( 'DELETE' ) } ${ eventPath } ` ) ;
324+ loggingQueue . push ( `${ styleText ( [ 'yellow' ] , 'DELETE' ) } ${ eventPath } ` ) ;
329325 break ;
330326 case 'rename' :
331327 loggingQueue . push (
332- `${ colors . blue ( 'RENAME' ) } ${ eventPath } => ${ removeLeadingSlash ( event . to ) } ` ,
328+ `${ styleText ( [ 'blue' ] , 'RENAME' ) } ${ eventPath } => ${ removeLeadingSlash ( event . to ) } ` ,
333329 ) ;
334330 break ;
335331 }
0 commit comments