File tree Expand file tree Collapse file tree 3 files changed +26
-3
lines changed
packages/angular_devkit/schematics/src Expand file tree Collapse file tree 3 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -96,9 +96,9 @@ export function noop(): Rule {
96
96
export function filter ( predicate : FilePredicate < boolean > ) : Rule {
97
97
return ( ( tree : Tree ) => {
98
98
// TODO: Remove VirtualTree usage in 7.0
99
- if ( tree instanceof VirtualTree ) {
99
+ if ( VirtualTree . isVirtualTree ( tree ) ) {
100
100
return new FilteredTree ( tree , predicate ) ;
101
- } else if ( tree instanceof HostTree ) {
101
+ } else if ( HostTree . isHostTree ( tree ) ) {
102
102
return new FilterHostTree ( tree , predicate ) ;
103
103
} else {
104
104
throw new SchematicsException ( 'Tree type is not supported.' ) ;
Original file line number Diff line number Diff line change @@ -109,6 +109,18 @@ export class HostTree implements Tree {
109
109
return this ;
110
110
}
111
111
112
+ static isHostTree ( tree : Tree ) : tree is HostTree {
113
+ if ( tree instanceof HostTree ) {
114
+ return true ;
115
+ }
116
+
117
+ if ( typeof tree === 'object' && typeof ( tree as HostTree ) . _ancestry === 'object' ) {
118
+ return true ;
119
+ }
120
+
121
+ return false ;
122
+ }
123
+
112
124
constructor ( protected _backend : virtualFs . ReadonlyHost < { } > = new virtualFs . Empty ( ) ) {
113
125
this . _record = new virtualFs . CordHost ( new virtualFs . SafeReadonlyHost ( _backend ) ) ;
114
126
this . _recordSync = new virtualFs . SyncDelegateHost ( this . _record ) ;
Original file line number Diff line number Diff line change @@ -104,7 +104,6 @@ export class VirtualDirEntry implements DirEntry {
104
104
}
105
105
}
106
106
107
-
108
107
/**
109
108
* The root class of most trees.
110
109
*/
@@ -114,6 +113,18 @@ export class VirtualTree implements Tree {
114
113
protected _root = new VirtualDirEntry ( this ) ;
115
114
protected _tree = new Map < Path , FileEntry > ( ) ;
116
115
116
+ static isVirtualTree ( tree : Tree ) : tree is VirtualTree {
117
+ if ( tree instanceof VirtualTree ) {
118
+ return true ;
119
+ }
120
+
121
+ if ( typeof tree === 'object' && typeof ( tree as VirtualTree ) . _copyTo === 'function' ) {
122
+ return true ;
123
+ }
124
+
125
+ return false ;
126
+ }
127
+
117
128
/**
118
129
* Normalize the path. Made available to subclasses to overload.
119
130
* @param path The path to normalize.
You can’t perform that action at this time.
0 commit comments