diff --git a/index.js b/index.js index e584de7d..997b97fe 100644 --- a/index.js +++ b/index.js @@ -2,6 +2,8 @@ /* eslint-env node */ +const VersionChecker = require('ember-cli-version-checker'); + module.exports = { name: 'ember-test-selectors', @@ -54,11 +56,20 @@ module.exports = { // add the StripDataTestPropertiesPlugin to the list of plugins used by // the `ember-cli-babel` addon if (this._stripTestSelectors && !this._registeredWithBabel) { + let checker = new VersionChecker(this).for('ember-cli-babel', 'npm'); + app.options = app.options || {}; app.options.babel = app.options.babel || {}; app.options.babel.plugins = app.options.babel.plugins || []; - app.options.babel.plugins.push(require('./strip-data-test-properties-plugin')); + if (checker.satisfies('^5.0.0')) { + app.options.babel.plugins.push(require('./strip-data-test-properties-plugin')); + } else if (checker.satisfies('^6.0.0')) { + app.options.babel.plugins.push(require('./strip-data-test-properties-plugin6')); + } else { + this.ui.writeWarnLine('ember-test-selectors: You are using an unsupported ember-cli-babel version. data-test' + + 'properties are not automatically stripped from your JS code.') + } this._registeredWithBabel = true; } diff --git a/package.json b/package.json index 8465a2ca..6f71c5bd 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,8 @@ "test:strip": "STRIP_TEST_SELECTORS=true ember test" }, "dependencies": { - "ember-cli-babel": "^5.1.7" + "ember-cli-babel": "^5.1.7", + "ember-cli-version-checker": "^1.2.0" }, "devDependencies": { "broccoli-asset-rev": "^2.4.5",