Skip to content

Commit 1f1d28d

Browse files
committed
fixup! fix(@angular-devkit/schematics): support delegating trees in the filter rule
1 parent 0fffc6d commit 1f1d28d

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

  • packages/angular_devkit/schematics/src/rules

‎packages/angular_devkit/schematics/src/rules/base.ts‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,12 @@ export function noop(): Rule {
7575

7676
export function filter(predicate: FilePredicate<boolean>): Rule {
7777
return (tree: Tree) => {
78-
// Trees such as `UnitTestTree` delegate to a `HostTree`, so filter the tree they wrap.
79-
let hostTree = tree;
80-
while (hostTree instanceof DelegateTree) {
81-
// cast to allow access
82-
hostTree = (hostTree as unknown as { _other: Tree })._other;
78+
if (tree instanceof DelegateTree) {
79+
tree = tree.branch();
8380
}
8481

85-
if (HostTree.isHostTree(hostTree)) {
86-
return new FilterHostTree(hostTree, predicate);
82+
if (HostTree.isHostTree(tree)) {
83+
return new FilterHostTree(tree, predicate);
8784
} else {
8885
throw new SchematicsException('Tree type is not supported.');
8986
}

0 commit comments

Comments
 (0)