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

bkr*_*bkr 4 json yeoman yeoman-generator

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

this.fs.copyTpl(
   this.templatePath('basicFiles/'),
   this.destinationPath(''),
   answers,
   {ignore:"_*.*"}
);

this.fs.copyTpl(
  [!*.*,this.templatePath('basicFiles/')],
  this.destinationPath(''),
  answers
);
Run Code Online (Sandbox Code Playgroud)

更笼统地说,想将每个basic / _exmaple.json合并(深层复制)到AdditionalConfig / example.json到desitnationPaht / exmaple.json(合并)。

每个想法都是受欢迎的:)。

lag*_*lex 5

因为fs.copyTpl您的{ignore:"_*.*"}需要位于第5个自变量对象(如语法所示)和内部globOptions键中:

this.fs.copyTpl(
  this.templatePath('**/*'), // from
  this.destinationRoot(),    // to
  {},  // context            // not here
  {},  // templateOptions    // not here
  { globOptions: {ignore:"_*.*"} } // < but here
)
Run Code Online (Sandbox Code Playgroud)

{dot: true}和其他类似选项相同。