javascriptember.jsember-cliember-cli-addons

How to add to an ember blueprint's renamedFiles property?


An ember blueprint has a static property called renamedFiles that by default renames gitignore from the files folder to .gitignore in the target folder.

The question is, how can I extend this list?

So far I tried these in the index.js of my blueprint, but they don't seem to work:

module.exports = {

  renamedFiles: {
    'something': 'somethingElse'
  },

  beforeInstall: function() {
    this._super.renamedFiles = {
      'something': 'somethingElse',
    };
  }
};

Solution

  • renamedFiles is a static property. You can access it via this.constructor.renamedFiles in beforeInstall hook. You can also modify it. Since this is a static propery, the modification may have some side-effects.

    The correct way to modify the file name is to use fileMapTokens hook. You don't need to manipulate renamedFiles.

    Here is a code sample:

    fileMapTokens(){
      return {
        something(){
          return 'somethingElse';
        },
        'my-funcy-file-name': function(){
          return 'myfuncyfilename';
        }
      };
    }