From 09fa5ec71bc754e62a80098266306ea5082ae72f Mon Sep 17 00:00:00 2001 From: Mark David Avery Date: Wed, 31 May 2017 22:22:16 -0700 Subject: [PATCH] fix(ensure environment): getting the 'root host', and using a shim if the find host method isn't present, Closes #231 --- index.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index fa88249..6491802 100644 --- a/index.js +++ b/index.js @@ -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); @@ -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);