1- import chokidar , { type FSWatcher } from 'chokidar' ;
1+ import chokidar from 'chokidar' ;
22
33/**
44 * Run css-modules-kit .d.ts generation in watch mode.
@@ -15,27 +15,18 @@ import chokidar, { type FSWatcher } from 'chokidar';
1515 * @throws {WatchInitializationError }
1616 */
1717export async function runCMKInWatchMode ( rootDir : string ) : Promise < void > {
18- const fsWatchers : FSWatcher [ ] = [ ] ;
19-
20- // Watch project files and report diagnostics on changes
21- const readyPromises : Promise < void > [ ] = [ ] ;
22- for ( const wildcardDirectory of [ { fileName : rootDir } ] ) {
23- const { promise, resolve } = Promise . withResolvers < void > ( ) ;
24- readyPromises . push ( promise ) ;
25- fsWatchers . push (
26- chokidar
27- . watch ( wildcardDirectory . fileName , { ignoreInitial : true } )
28- . on ( 'change' , ( fileName ) => {
29- console . log ( 'change event: ' , fileName ) ;
30- if ( fileName . endsWith ( 'a.module.css' ) ) {
31- globalThis . changeCount ++ ;
32- }
33- } )
34- . on ( 'raw' , ( eventName , fileName , details ) => {
35- console . log ( 'raw event:' , { fileName } ) ;
36- } )
37- . on ( 'ready' , ( ) => resolve ( ) ) ,
38- ) ;
39- }
40- await Promise . all ( readyPromises ) ;
18+ const { promise, resolve } = Promise . withResolvers < void > ( ) ;
19+ chokidar
20+ . watch ( rootDir , { ignoreInitial : true } )
21+ . on ( 'change' , ( fileName ) => {
22+ console . log ( 'change event: ' , fileName ) ;
23+ if ( fileName . endsWith ( 'a.module.css' ) ) {
24+ globalThis . changeCount ++ ;
25+ }
26+ } )
27+ . on ( 'raw' , ( eventName , fileName , details ) => {
28+ console . log ( 'raw event:' , { fileName } ) ;
29+ } )
30+ . on ( 'ready' , ( ) => resolve ( ) ) ;
31+ await promise ;
4132}
0 commit comments