3
votes

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.

2

2 Answers

3
votes

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.

0
votes

I have managed to solve the problem. Don't know if it is the best way. So I am able to obtain the absolute process path in node just by using process.cwd() Then I can simply append a config file name to the end of the string to get my config file absolute path.

If there are any ember-cli specific ways that I should be doing this then please let me know.