Skip to content

Commit

Permalink
Merge pull request #1632 from bcardarella/bc-fix-addon-history-support
Browse files Browse the repository at this point in the history
Allow addons to use history-support middleware
  • Loading branch information
bcardarella committed Aug 10, 2014
2 parents 9a192e9 + 1c49501 commit b630096
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* [ENHANCEMENT] Addon blueprint [#1374](https://github.com/stefanpenner/ember-cli/pull/1374)
* [BUGFIX] Fix addons with empty directories [#]()
* [BUGFIX] Fix tests/helpers/start-app.js location from addon generator [#1626](https://github.com/stefanpenner/ember-cli/pull/1626)
* [BUGFIX] Allow addons to use history support middleware [#1632](https://github.com/stefanpenner/ember-cli/pull/1632)

### 0.0.40

Expand Down
3 changes: 3 additions & 0 deletions blueprints/addon/files/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"keywords": [
"ember-addon"
],
"ember-addon": {
"configPath": "tests/dummy/config"
},
"author": "",
"license": "MIT",
"devDependencies": {
Expand Down
9 changes: 7 additions & 2 deletions lib/models/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,13 @@ Project.prototype.isEmberCLIAddon = function() {


Project.prototype.config = function(env) {
if (fs.existsSync(path.join(this.root, 'config', 'environment.js'))) {
return this.require('./config/environment')(env);
var configPath = 'config';

if (this.pkg['ember-addon'] && this.pkg['ember-addon']['configPath']) {
configPath = this.pkg['ember-addon']['configPath'];
}
if (fs.existsSync(path.join(this.root, configPath, 'environment.js'))) {
return this.require('./' + path.join(configPath, 'environment'))(env);
} else {
return { };
}
Expand Down
36 changes: 35 additions & 1 deletion tests/unit/models/project-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var emberCLIVersion = require('../../../lib/utilities/ember-cli-version');
describe('models/project.js', function() {
var project, projectPath;

describe('Project.prototype.config', function() {
describe('Project.prototype.config default', function() {
var called = false;
projectPath = process.cwd() + '/tmp/test-app';

Expand Down Expand Up @@ -41,6 +41,40 @@ describe('models/project.js', function() {
});
});

describe('Project.prototype.config custom config path from addon', function() {
var called = false;
projectPath = process.cwd() + '/tmp/test-app';

before(function() {
tmp.setup(projectPath);

touch(projectPath + '/tests/dummy/config/environment.js', {
baseURL: '/foo/bar'
});

project = new Project(projectPath, { });
project.pkg = {
'ember-addon': {
'configPath': 'tests/dummy/config'
}
};
project.require = function() {
called = true;
return function() {};
};

});

after(function() {
tmp.teardown(projectPath);
});

it('config() finds and requires tests/dummy/config/environment', function() {
project.config('development');
assert.equal(called, true);
});
});

describe('addons', function() {
before(function() {
projectPath = path.resolve(__dirname, '../../fixtures/addon/simple');
Expand Down

0 comments on commit b630096

Please sign in to comment.