Search code examples
jsonyeomanyeoman-generator

How to ignore files in Yeoman with fs.copyTpl


how can i ignore files? i want to exclude all file starting with _ in any subdirectory. i have no success with these two approaches:

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

this.fs.copyTpl(
  [!*.*,this.templatePath('basicFiles/')],
  this.destinationPath(''),
  answers
);

More general, would like to merge(deep copy) every basic/_exmaple.json into additionalConfig/example.json to desitnationPaht/exmaple.json (merged).

Every idea is welcome :).


Solution

  • For fs.copyTpl your {ignore:"_*.*"} needs to be in the 5th argument object (as the syntax says) and inside globOptions key:

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

    Same for {dot: true} and other such options.