From da40e7755117fefacb9031fe37cad1ef90047e61 Mon Sep 17 00:00:00 2001 From: Kashif Khan Date: Tue, 15 Nov 2016 09:15:12 +1100 Subject: [PATCH 1/2] Fix #9: Support ember LTS 2.4.x and node older versions --- index.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 3231687..eb35f7b 100644 --- a/index.js +++ b/index.js @@ -1,15 +1,25 @@ /* jshint node: true */ 'use strict'; +var path = require('path'); var Funnel = require('broccoli-funnel'); module.exports = { name: 'ember-test-with-data', - included(app) { + included: function(app) { var registry = app.registry; var options = app.options || {}; this.env = app.env; + var configPath = options.configPath; + + + // NOTE: For ember-cli >= 2.6.0-beta.3, project.configPath() returns absolute path + // while older ember-cli versions return path relative to project root + if (!path.isAbsolute(configPath)) { + configPath = path.join(app.project.root, configPath); + } + if (!this.env || !configPath) { return; } var config = require(configPath)(this.env) || {}; @@ -27,9 +37,9 @@ module.exports = { } }, - treeForAddon() { + treeForAddon: function() { var tree = this._super.treeForAddon.apply(this, arguments); - const hiddenEnvironments = this.hiddenEnvironments || ['production']; + var hiddenEnvironments = this.hiddenEnvironments || ['production']; if (hiddenEnvironments.indexOf(this.env) !== -1) { this.ui.writeLine('Stripping all data test attributes'); tree = new Funnel(tree, { exclude: [ /add-data-test-to-view/ ] }); From c427d2debfaca720267c3c16c4fdacdaf99b497c Mon Sep 17 00:00:00 2001 From: Kashif Khan Date: Mon, 5 Dec 2016 16:51:21 +1100 Subject: [PATCH 2/2] Fix do not access configPath before checking it for undefined --- index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/index.js b/index.js index eb35f7b..fdc6575 100644 --- a/index.js +++ b/index.js @@ -13,6 +13,7 @@ module.exports = { var configPath = options.configPath; + if (!this.env || !configPath) { return; } // NOTE: For ember-cli >= 2.6.0-beta.3, project.configPath() returns absolute path // while older ember-cli versions return path relative to project root @@ -20,8 +21,6 @@ module.exports = { configPath = path.join(app.project.root, configPath); } - if (!this.env || !configPath) { return; } - var config = require(configPath)(this.env) || {}; var addonSettings = config['ember-test-with-data'] || {}; this.hiddenEnvironments = addonSettings['hiddenEnvironments'] || ['production'];