Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 角度示意图树:如何排除?_Angular_Angular Schematics - Fatal编程技术网

Angular 角度示意图树:如何排除?

Angular 角度示意图树:如何排除?,angular,angular-schematics,Angular,Angular Schematics,我有一棵树,它的根是项目根目录 我想使用forEach应用一个规则,它遍历树中的所有文件。这是可行的,但速度非常慢,因为node_模块也是树的一部分 我怎么能排除那个目录 我试过: const templateSource = apply(source(tree), [ filter(path => { return !path.includes('node_modules'); }),

我有一棵树,它的根是项目根目录

我想使用forEach应用一个规则,它遍历树中的所有文件。这是可行的,但速度非常慢,因为node_模块也是树的一部分

我怎么能排除那个目录

我试过:

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

            forEach((entry: FileEntry) => {
            ....
            }
但这总是失败的:

错误:路径“/some/Path/some.file”已存在


我看不到任何方法可以帮助我从树上分支或类似的东西。我只需要将forEach应用于树的一部分。实现此目的的最佳方法是什么?

您似乎正在尝试创建一个已经存在的文件。 使用strategy.override

if (tree.exists(file.path)) tree.overwrite(file.path, file.content);

这些策略似乎没有任何作用。我的意思是,覆盖、allowCreateConflict和其他似乎都被忽略了。原理图仍然抱怨现有文件。请使用tree.exists和tree.override方法