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?

ahmeticat
  • 1,899
  • 1
  • 13
  • 28
user2297996
  • 1,382
  • 3
  • 18
  • 28

1 Answers1

1

it seems that you are trying to create a file that is already exists. use strategy.override.

if (tree.exists(file.path)) tree.overwrite(file.path, file.content);
Sh eldeeb
  • 1,589
  • 3
  • 18
  • 41