0

I've got a Tree whose root is the project root dir.

I would like to apply a rule using forEach, which iterates through all the files in the tree. This works, but it's very slow since node_modules is also part of the tree.

How could I exclude that dir?

I tried:

 const templateSource = apply(source(tree), [
            filter(path => {
                return !path.includes('node_modules');
            }),

            forEach((entry: FileEntry) => {
            ....
            }

But this always fails:

Error: Path "/some/path/some.file" already exist.

I don't see any methods which could help me to branch off the tree or something like that. I need to apply the forEach to only part of the tree. What's the best way to achieve this?

4

1 回答 1

1

您似乎正在尝试创建一个已经存在的文件。使用策略。覆盖。

if (tree.exists(file.path)) tree.overwrite(file.path, file.content);
于 2020-01-03T05:30:25.430 回答