Ember-CLI Addon Design Issue ( import w/ Test and Addon)


#1

Hello. I am working on https://github.com/lindenlab/ember-cli-test-pretend

I have a design issue that is essentially a dependency injection problem.

I need to a) use the addon from my test b) use the addon from my included project c) specify a file that can be modifed by the user (configuration)

I have been able to do all 3 of these - except I cannot figure out a way to do it such that i’m actually using the addon directory properly.

My code needs to import the configuration file, which in the context of test would be inside the dummy app which would break case (b), if i specify an import © according to where a blueprint can generate a file then I break (a)

Can anyone see a way to use the blueprint to generate a file ie “config/test-pretend-config.js” in such a way that it can be imported from the addon directory and located when running the test harness ( which sees any files from the addon directory as being outside the dummy app)

Thank you


#2

I realized that I had given myself a clue to solving this in the actual post. I solved this problem by using dependency injection pattern to reverse the order of includes.

Now i have my main library in the ‘addon/’ directory and the blueprint generates a configuration file that loads the main library, and then installs configuration, and then returns the actual main library as export.

This way the user can import the helper config as the actual library and I can do a), b) and c) cases above.