node.jsember.jsember-cliember-cli-addons

Ember-cli addon read configurations


I am trying to create an ember-cli addon and I want this addon to include custom command. This part I have already done by creating a lib/commands file structure and including the script that will run the command then used includedCommands in the addon index.js.

The part I am struggling with is I want the command to be able to read a configuration file within the host applications directory. How can I do this? If I could find out the host apps absolute path I suppose I could parse a file using built in node tools but how do I find this path?

If there are better ways to accomplish this task I am all ears.


Solution

  • In your commands run function, you can access this.project which provides details about the project.

    What you want to use is this.project.root.. it's the root directory of the project.