How are you upgrading the needs array?

We’re upgrading to EmberCLI and I just ran into a problem with the needs array. We have a controller in app/controllers/folders/ that we require in a number of other controllers. Currently, the needs array uses dots:

needs: ['folders.commands']

But, EmberCLI needs a slash to find the controller:

needs: ['folders/commands']

The solution I’ve come up with so far is to add the following sed command to our migration script:

  sed --regexp-extended --in-place '/needs:/s/\./\//' $new_path

where $new_path is the name of the file in the ember-cli repo.

This is the first “show stopper” where I’ve hit a real conflict between Ember and EmberCLI. For just about every other case, I’ve been able to find a syntax that works in both. Anyway, I was just interested to see how other people were dealing with needs.


Slashes is the appropriate solution here. However, I would move away from using needs if you’re going through the upgrade path now. The alternative, and preferred way going forward, is to use Ember.inject.controller

Slashes will still be needed.

We’ll start using services after the upgrade but during this work I need to find a solution that supports both ember and ember-cli. It’s a pretty big challenge upgrading 180k lines of code without stopping the rest of the team from adding features, fixing bugs, etc… So, I really can’t start any sort of refactor until the upgrade is done.

Ember.inject.controller not Ember.inject.service