@@ -15,38 +15,33 @@ import { NodeModulesEngineHost } from './node-module-engine-host';
15
15
* revert back to using node modules resolution. This is done for testing.
16
16
*/
17
17
export class NodeModulesTestEngineHost extends NodeModulesEngineHost {
18
- private _collections = new Map < string , string > ( ) ;
19
- private _tasks = [ ] as TaskConfiguration [ ] ;
18
+ #collections = new Map < string , string > ( ) ;
19
+ #tasks: TaskConfiguration [ ] = [ ] ;
20
20
21
21
get tasks ( ) {
22
- return this . _tasks ;
22
+ return this . #tasks ;
23
23
}
24
24
25
25
clearTasks ( ) {
26
- this . _tasks = [ ] ;
26
+ this . #tasks = [ ] ;
27
27
}
28
28
29
29
registerCollection ( name : string , path : string ) {
30
- this . _collections . set ( name , path ) ;
30
+ this . #collections . set ( name , path ) ;
31
31
}
32
32
33
33
override transformContext ( context : FileSystemSchematicContext ) : FileSystemSchematicContext {
34
- const oldAddTask = context . addTask ;
35
- context . addTask = ( task : TaskConfigurationGenerator < { } > , dependencies ?: Array < TaskId > ) => {
36
- this . _tasks . push ( task . toConfiguration ( ) ) ;
34
+ const oldAddTask = context . addTask . bind ( context ) ;
35
+ context . addTask = ( task : TaskConfigurationGenerator , dependencies ?: TaskId [ ] ) => {
36
+ this . #tasks . push ( task . toConfiguration ( ) ) ;
37
37
38
- return oldAddTask . call ( context , task , dependencies ) ;
38
+ return oldAddTask ( task , dependencies ) ;
39
39
} ;
40
40
41
41
return context ;
42
42
}
43
43
44
44
protected override _resolveCollectionPath ( name : string , requester ?: string ) : string {
45
- const maybePath = this . _collections . get ( name ) ;
46
- if ( maybePath ) {
47
- return maybePath ;
48
- }
49
-
50
- return super . _resolveCollectionPath ( name , requester ) ;
45
+ return this . #collections. get ( name ) ?? super . _resolveCollectionPath ( name , requester ) ;
51
46
}
52
47
}
0 commit comments