1
1
// @ts -check
2
2
import { CancelToken } from "@esfx/canceltoken" ;
3
3
import assert from "assert" ;
4
- import chalk from "chalk" ;
5
4
import chokidar from "chokidar" ;
6
5
import esbuild from "esbuild" ;
7
6
import { EventEmitter } from "events" ;
8
7
import fs from "fs" ;
9
8
import { glob } from "glob" ;
10
9
import { task } from "hereby" ;
11
10
import path from "path" ;
11
+ import pc from "picocolors" ;
12
12
13
13
import { localizationDirectories } from "./scripts/build/localization.mjs" ;
14
14
import cmdLineOptions from "./scripts/build/options.mjs" ;
@@ -399,7 +399,7 @@ function entrypointBuildTask(options) {
399
399
// allowing them to operate as regular tasks, while creating unresolved promises
400
400
// in the background that keep the process running after all tasks have exited.
401
401
if ( ! printedWatchWarning ) {
402
- console . error ( chalk . yellowBright ( "Warning: watch mode is incomplete and may not work as expected. Use at your own risk." ) ) ;
402
+ console . error ( pc . yellowBright ( "Warning: watch mode is incomplete and may not work as expected. Use at your own risk." ) ) ;
403
403
printedWatchWarning = true ;
404
404
}
405
405
@@ -707,7 +707,7 @@ export const runTestsAndWatch = task({
707
707
dependencies : [ watchTests ] ,
708
708
run : async ( ) => {
709
709
if ( ! cmdLineOptions . tests && ! cmdLineOptions . failed ) {
710
- console . log ( chalk . redBright ( `You must specifiy either --tests/-t or --failed to use 'runtests-watch'.` ) ) ;
710
+ console . log ( pc . redBright ( `You must specifiy either --tests/-t or --failed to use 'runtests-watch'.` ) ) ;
711
711
return ;
712
712
}
713
713
@@ -719,9 +719,8 @@ export const runTestsAndWatch = task({
719
719
720
720
const testsChangedDebouncer = new Debouncer ( 1_000 , endRunTests ) ;
721
721
const testCaseWatcher = chokidar . watch ( [
722
- "tests/cases/**/*.*" ,
723
- "tests/lib/**/*.*" ,
724
- "tests/projects/**/*.*" ,
722
+ "tests/cases" ,
723
+ "tests/lib" ,
725
724
] , {
726
725
ignorePermissionErrors : true ,
727
726
alwaysStat : true ,
@@ -746,7 +745,7 @@ export const runTestsAndWatch = task({
746
745
running = false ;
747
746
}
748
747
if ( watching ) {
749
- console . log ( chalk . yellowBright ( `[watch] test run complete, waiting for changes...` ) ) ;
748
+ console . log ( pc . yellowBright ( `[watch] test run complete, waiting for changes...` ) ) ;
750
749
await promise ;
751
750
}
752
751
}
@@ -756,7 +755,7 @@ export const runTestsAndWatch = task({
756
755
}
757
756
758
757
/**
759
- * @param {'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir' } eventName
758
+ * @param {'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir' | 'all' | 'ready' | 'raw' | 'error' } eventName
760
759
* @param {string } path
761
760
* @param {fs.Stats | undefined } stats
762
761
*/
@@ -783,9 +782,9 @@ export const runTestsAndWatch = task({
783
782
*/
784
783
function beginRunTests ( path ) {
785
784
if ( testsChangedDebouncer . empty ) {
786
- console . log ( chalk . yellowBright ( `[watch] tests changed due to '${ path } ', restarting...` ) ) ;
785
+ console . log ( pc . yellowBright ( `[watch] tests changed due to '${ path } ', restarting...` ) ) ;
787
786
if ( running ) {
788
- console . log ( chalk . yellowBright ( "[watch] aborting in-progress test run..." ) ) ;
787
+ console . log ( pc . yellowBright ( "[watch] aborting in-progress test run..." ) ) ;
789
788
}
790
789
testsChangedCancelSource . cancel ( ) ;
791
790
testsChangedCancelSource = CancelToken . source ( ) ;
@@ -803,7 +802,7 @@ export const runTestsAndWatch = task({
803
802
function endWatchMode ( ) {
804
803
if ( watching ) {
805
804
watching = false ;
806
- console . log ( chalk . yellowBright ( "[watch] exiting watch mode..." ) ) ;
805
+ console . log ( pc . yellowBright ( "[watch] exiting watch mode..." ) ) ;
807
806
testsChangedCancelSource . cancel ( ) ;
808
807
testCaseWatcher . close ( ) ;
809
808
watchTestsEmitter . off ( "rebuild" , onRebuild ) ;
0 commit comments