Skip to content

Commit

Permalink
fix(ensure environment): getting the 'root host', and using a shim if…
Browse files Browse the repository at this point in the history
… the find host method isn't present, Closes #231
  • Loading branch information
webark committed Jun 1, 2017
1 parent 60aef70 commit 09fa5ec
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,21 @@ module.exports = {
return projectRoot;
},

_getEnvironment: function() {
if (!this._findHost) {
this._findHost = function findHostShim() {
let current = this;
let app;
do {
app = current.app || app;
} while (current.parent.parent && (current = current.parent));
return app;
};
}

return this._findHost().env;
},

included: function(app) {
this._super.included.apply(this, arguments);

Expand All @@ -70,7 +85,7 @@ module.exports = {
this.parent.treeForParentAddonStyles = this.treeForParentAddonStyles.bind(this);
}

this.appConfig = app.project.config(app.env);
this.appConfig = app.project.config(this._getEnvironment());
this.addonConfig = this.appConfig['ember-component-css'] || {};
this.classicStyleDir = this.addonConfig.classicStyleDir || 'component-styles';
this.terseClassNames = Boolean(this.addonConfig.terseClassNames);
Expand Down

0 comments on commit 09fa5ec

Please # to comment.