@@ -13,6 +13,7 @@ import {readFileSync} from 'fs';
1313import { testApiGolden } from './test_api_report.js' ;
1414import * as fs from 'fs' ;
1515import { Piscina } from 'piscina' ;
16+ import { styleText } from 'util' ;
1617
1718/** Interface describing contents of a `package.json`. */
1819export interface PackageJson {
@@ -36,9 +37,8 @@ async function main(
3637) {
3738 /** Whether the goldenDir provided is actually pointing to a single file. */
3839 const singleFileMode = fs . existsSync ( goldenDir ) && fs . statSync ( goldenDir ) . isFile ( ) ;
39- // TODO(ESM) This can be replaced with an actual ESM import when `ts_library` is
40- // guaranteed to be ESM-only and supports the `mts` extension.
41- const chalk = { red : ( v : string ) => v , yellow : ( v : string ) => v } ;
40+ const red = styleText . bind ( null , 'red' ) ;
41+ const yellow = styleText . bind ( null , 'yellow' ) ;
4242
4343 const packageJsonPath = path . join ( npmPackageDir , 'package.json' ) ;
4444 const packageJson = JSON . parse ( readFileSync ( packageJsonPath , 'utf8' ) ) as PackageJson ;
@@ -124,16 +124,16 @@ async function main(
124124 console . error ( Array ( 80 ) . fill ( '=' ) . join ( '' ) ) ;
125125 if ( singleFileMode ) {
126126 console . error (
127- chalk . red (
127+ red (
128128 `The golden is out of date and can be updated by running:\n - bazel run ${ process . env . TEST_TARGET } .accept` ,
129129 ) ,
130130 ) ;
131131 } else {
132- console . error ( chalk . red ( `The following goldens are outdated:` ) ) ;
132+ console . error ( red ( `The following goldens are outdated:` ) ) ;
133133 outdatedGoldens . forEach ( ( name ) => console . info ( `- ${ name } ` ) ) ;
134134 console . info ( ) ;
135135 console . info (
136- chalk . yellow (
136+ yellow (
137137 `The goldens can be updated by running:\n - bazel run ${ process . env . TEST_TARGET } .accept` ,
138138 ) ,
139139 ) ;
0 commit comments