3

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.

tomasbasham
  • 1,695
  • 2
  • 18
  • 37

2 Answers2

3

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.

jmurphyau
  • 2,309
  • 13
  • 11
0

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.

tomasbasham
  • 1,695
  • 2
  • 18
  • 37