@@ -25,7 +25,6 @@ import * as fs from "fs/promises"
25
25
import {
26
26
EMPTY ,
27
27
Observable ,
28
- concatAll ,
29
28
filter ,
30
29
from ,
31
30
fromEvent ,
@@ -35,6 +34,7 @@ import {
35
34
map ,
36
35
mergeWith ,
37
36
of ,
37
+ switchMap ,
38
38
tap
39
39
} from "rxjs"
40
40
import glob from "tiny-glob"
@@ -110,33 +110,34 @@ export function resolve(
110
110
return from ( glob ( pattern , { dot : true , ...options } ) )
111
111
. pipe (
112
112
catchError ( ( ) => EMPTY ) ,
113
- concatAll ( ) ,
113
+ switchMap ( files => from ( files ) . pipe (
114
+
115
+ /* Start file watcher */
116
+ options ?. watch
117
+ ? mergeWith ( watch ( files , options ) )
118
+ : identity
119
+ ) ) ,
114
120
115
121
/* Build overrides */
116
122
! process . argv . includes ( "--all" )
117
123
? filter ( file => ! file . startsWith ( ".overrides/" ) )
118
124
: identity ,
119
-
120
- /* Start file watcher */
121
- options ?. watch
122
- ? mergeWith ( watch ( pattern , options ) )
123
- : identity
124
125
)
125
126
}
126
127
127
128
/**
128
- * Watch all files matching the given pattern
129
+ * Watch all given files
129
130
*
130
- * @param pattern - Pattern
131
+ * @param files - Files
131
132
* @param options - Options
132
133
*
133
134
* @returns File observable
134
135
*/
135
136
export function watch (
136
- pattern : string , options : WatchOptions
137
+ files : string [ ] , options : WatchOptions
137
138
) : Observable < string > {
138
139
return fromEvent (
139
- chokidar . watch ( pattern , options ) ,
140
+ chokidar . watch ( files , options ) ,
140
141
"change" , file => file // see https://t.ly/dli_k
141
142
) as Observable < string >
142
143
}
0 commit comments