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

标签 json yeoman yeoman-generator

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

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/

相关文章:

javascript - 使用 jQuery 从 JSON 创建动态嵌套列表

yeoman - jhipster 应用程序文件在错误的目录中生成

javascript - 在服务器上发布项目

javascript - 如果使用 grunt-contrib-imagemin 优化图像,如何处理 Handlebars 模板中的图像

angularjs - 有没有一些generator可以生成angular component api文档?

javascript - 安装 npm 依赖项 webtorrent - 错误 : Can't resolve 'fs' - Fountain-Js (Yeoman)

c++ - 为了 jsoncpp (c++) 编写

c# - 反序列化不一致的 JSON 属性

javascript - ReactJS:无法将 api 响应渲染到 h2 标签中,但可以将其记录到控制台

npm - 优医生 : command not found when installing yo from terminal