refactor(@angular-devkit/schematics): avoid for await...of with promise arrays

The upcoming version of typescript Eslint rules will fail the `await-thenable`
rule for cases of for await...of that use promise arrays. This change
removes the usage to avoid lint failures during the version update.
Ref: https://typescript-eslint.io/rules/await-thenable/#async-iteration-for-awaitof-loops
This commit is contained in:
Charles Lyding 2024-10-02 15:46:28 -04:00 committed by Charles
parent 909cfacf8a
commit 62a99b70b8

View File

@ -35,8 +35,14 @@ export function empty(): Source {
export function chain(rules: Iterable<Rule> | AsyncIterable<Rule>): Rule {
return async (initialTree, context) => {
let intermediateTree: Observable<Tree> | undefined;
for await (const rule of rules) {
intermediateTree = callRule(rule, intermediateTree ?? initialTree, context);
if (Symbol.asyncIterator in rules) {
for await (const rule of rules) {
intermediateTree = callRule(rule, intermediateTree ?? initialTree, context);
}
} else {
for (const rule of rules) {
intermediateTree = callRule(rule, intermediateTree ?? initialTree, context);
}
}
return () => intermediateTree;