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 {
9696export function filter ( predicate : FilePredicate < boolean > ) : Rule {
9797 return ( ( tree : Tree ) => {
9898 // TODO: Remove VirtualTree usage in 7.0
99- if ( tree instanceof VirtualTree ) {
99+ if ( VirtualTree . isVirtualTree ( tree ) ) {
100100 return new FilteredTree ( tree , predicate ) ;
101- } else if ( tree instanceof HostTree ) {
101+ } else if ( HostTree . isHostTree ( tree ) ) {
102102 return new FilterHostTree ( tree , predicate ) ;
103103 } else {
104104 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 {
109109 return this ;
110110 }
111111
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+
112124 constructor ( protected _backend : virtualFs . ReadonlyHost < { } > = new virtualFs . Empty ( ) ) {
113125 this . _record = new virtualFs . CordHost ( new virtualFs . SafeReadonlyHost ( _backend ) ) ;
114126 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 {
104104 }
105105}
106106
107-
108107/**
109108 * The root class of most trees.
110109 */
@@ -114,6 +113,18 @@ export class VirtualTree implements Tree {
114113 protected _root = new VirtualDirEntry ( this ) ;
115114 protected _tree = new Map < Path , FileEntry > ( ) ;
116115
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+
117128 /**
118129 * Normalize the path. Made available to subclasses to overload.
119130 * @param path The path to normalize.
You can’t perform that action at this time.
0 commit comments