Repository: ember-cli/ember-try (js)

Issue:
Feature Request: support promises in dependencies...
In order to support using ember-source from canary, beta, release channels we will need to fetch the correct tarball location to use.

A rough sketch of that API which we have been kicking around is something like this:

```js
const getChannelURL = require('ember-source-channel-url');

module.exports = {
  scenarios: [
    {
      name: 'ember-release',
      npm: {
        devDependencies: {
          'ember-source': getChannelURL('release')
        }
      }
    },
    {
      name: 'ember-beta',
      npm: {
        devDependencies: {
          'ember-source': getChannelURL('beta')
        }
      }
    },
    {
      name: 'ember-canary',
      npm: {
        devDependencies: {
          'ember-source': getChannelURL('canary')
        }
      }
    }
  ]
};
```

The `ember-source-channel-url` package is _very very_ simple package which fetches the latest canary tarball asset path, and returns it.  Due to it having to fetch data from S3, the package must return a promise.

---

### Feature Request

Update ember-try's internals to resolve promises as values in the scenario configuration...

Pull request:
Support config files returning a promise
Resolves #172 

Patch:
diff --git a/lib/utils/config.js b/lib/utils/config.js
index 3910fe8..71d6bbe 100644
--- a/lib/utils/config.js
+++ b/lib/utils/config.js
@@ -24,21 +24,23 @@ function getBaseConfig(options) {
     debug('Config file does not exist %s', configFile);
   }
 
-  if (configData && configData.scenarios && !configData.useVersionCompatibility && !options.versionCompatibility) {
-    return RSVP.resolve(configData);
-  }
+  return RSVP.resolve(configData).then(function(data) {
+    if (data && data.scenarios && !data.useVersionCompatibility && !options.versionCompatibility) {
+      return RSVP.resolve(data);
+    }
 
-  var versionCompatibility = options.versionCompatibility || versionCompatibilityFromPackageJSON(options.project.root);
+    var versionCompatibility = options.versionCompatibility || versionCompatibilityFromPackageJSON(options.project.root);
 
-  if (versionCompatibility) {
-    // Required lazily to improve startup speed.
-    var autoScenarioConfigForEmber = require('ember-try-config');
-    return autoScenarioConfigForEmber({ versionCompatibility: versionCompatibility, project: options.project }).then(function(autoConfig) {
-      return mergeAutoConfigAndConfigFileData(autoConfig, configData);
-    });
-  } else {
-    return RSVP.resolve(defaultConfig());
-  }
+    if (versionCompatibility) {
+      // Required lazily to improve startup speed.
+      var autoScenarioConfigForEmber = require('ember-try-config');
+      return autoScenarioConfigForEmber({ versionCompatibility: versionCompatibility, project: options.project }).then(function(autoConfig) {
+        return mergeAutoConfigAndConfigFileData(autoConfig, data);
+      });
+    } else {
+      return RSVP.resolve(defaultConfig());
+    }
+  });
 }
 
 function config(options) {


Test patch:
diff --git a/test/utils/config-test.js b/test/utils/config-test.js
index c5ab4ee..7a02076 100644
--- a/test/utils/config-test.js
+++ b/test/utils/config-test.js
@@ -166,6 +166,22 @@ describe('utils/config', function() {
     });
   });
 
+  it('config file can return a promise', function() {
+    var configFile = 'module.exports = function() {' +
+                     '  return new Promise(function (resolve) {' +
+                     '    var scenarios = [' +
+                     '      { bar: "baz" }' +
+                     '    ];' +
+                     '    resolve({ scenarios: scenarios });' +
+                     '  });' +
+                     '};';
+    generateConfigFile(configFile);
+    return getConfig({ project: project }).then(function(config) {
+      expect(config.scenarios).to.have.lengthOf(1);
+      expect(config.scenarios[0].bar).to.equal('baz');
+    });
+  });
+
   it('config file exporting a function is passed the project', function() {
     generateConfigFile('module.exports =  function(project) { return { scenarios: [ { foo: project.blah }] } };');