如何使用fs.copyTpl忽略Yeoman中的文件

问题描述 投票:4回答:1

我怎么能忽略文件?我想在任何子目录中排除以_开头的所有文件。我对这两种方法没有成功:

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(merged)。

欢迎任何想法:)。

json yeoman yeoman-generator
1个回答
4
投票

对于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}和其他类似选项也是如此。

© www.soinside.com 2019 - 2024. All rights reserved.