diff --git a/index.js b/index.js index 3231687..fdc6575 100644 --- a/index.js +++ b/index.js @@ -1,17 +1,26 @@ /* 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; + 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 + if (!path.isAbsolute(configPath)) { + configPath = path.join(app.project.root, configPath); + } + var config = require(configPath)(this.env) || {}; var addonSettings = config['ember-test-with-data'] || {}; this.hiddenEnvironments = addonSettings['hiddenEnvironments'] || ['production']; @@ -27,9 +36,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/ ] });