88 */
99import { Architect , BuilderInfo , BuilderProgressState , Target } from '@angular-devkit/architect' ;
1010import { WorkspaceNodeModulesArchitectHost } from '@angular-devkit/architect/node' ;
11- import { logging , schema , tags , terminal , workspaces } from '@angular-devkit/core' ;
11+ import { logging , schema , tags , workspaces } from '@angular-devkit/core' ;
1212import { NodeJsSyncHost , createConsoleLogger } from '@angular-devkit/core/node' ;
13+ import * as ansiColors from 'ansi-colors' ;
1314import { existsSync } from 'fs' ;
1415import * as minimist from 'minimist' ;
1516import * as path from 'path' ;
@@ -68,6 +69,10 @@ interface BarInfo {
6869 target?: Target;
6970}
7071
72+ // Create a separate instance to prevent unintended global changes to the color configuration
73+ // Create function is not defined in the typings. See: https://github.com/doowb/ansi-colors/pull/44
74+ const colors = (ansiColors as typeof ansiColors & { create: () => typeof ansiColors }).create();
75+
7176async function _executeTarget(
7277 parentLogger: logging.Logger,
7378 workspace: workspaces.WorkspaceDefinition,
@@ -139,9 +144,9 @@ async function _executeTarget(
139144 .pipe(
140145 tap(result => {
141146 if (result.success) {
142- parentLogger.info(terminal .green('SUCCESS'));
147+ parentLogger.info(colors .green('SUCCESS'));
143148 } else {
144- parentLogger.info(terminal.yellow ('FAILURE'));
149+ parentLogger.info(colors.red ('FAILURE'));
145150 }
146151 parentLogger.info('Result: ' + JSON.stringify({ ...result, info: undefined }, null, 4));
147152
@@ -157,7 +162,7 @@ async function _executeTarget(
157162
158163 return success ? 0 : 1;
159164 } catch (err) {
160- parentLogger.info(terminal .red('ERROR'));
165+ parentLogger.info(colors .red('ERROR'));
161166 parentLogger.info('\nLogs:');
162167 logs.forEach(l => parentLogger.next(l));
163168
@@ -173,7 +178,13 @@ async function main(args: string[]): Promise<number> {
173178 const argv = minimist(args, { boolean: ['help'] });
174179
175180 /** Create the DevKit Logger used through the CLI. */
176- const logger = createConsoleLogger(argv['verbose']);
181+ const logger = createConsoleLogger(argv['verbose'], process.stdout, process.stderr, {
182+ info: s => s,
183+ debug: s => s,
184+ warn: s => colors.bold.yellow(s),
185+ error: s => colors.bold.red(s),
186+ fatal: s => colors.bold.red(s),
187+ });
177188
178189 // Check the target.
179190 const targetStr = argv._[0] || '';
0 commit comments