如何忽略文件?我想排除任何子目录中以 _ 开头的所有文件。我使用这两种方法没有成功:
this.fs.copyTpl(
this.templatePath('basicFiles/'),
this.destinationPath(''),
answers,
{ignore:"_*.*"}
);
this.fs.copyTpl(
[!*.*,this.templatePath('basicFiles/')],
this.destinationPath(''),
answers
);
更一般地说,希望将每个 basic/_exmaple.json 合并(深度复制)到additionalConfig/example.json 到 desitnationPaht/exmaple.json (合并)。
欢迎提出任何想法:)。
最佳答案
对于fs.copyTpl
,您的{ignore:"_*.*"}
需要位于第5参数对象中(作为syntax 说)和里面的 globOptions
键:
this.fs.copyTpl(
this.templatePath('**/*'), // from
this.destinationRoot(), // to
{}, // context // not here
{}, // templateOptions // not here
{ globOptions: {ignore:"_*.*"} } // < but here
)
与 {dot: true}
和其他此类选项相同。
关于json - 如何使用 fs.copyTpl 忽略 Yeoman 中的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43622445/