From 44e667365d07be784cfd62fa55c6b50496cdfa49 Mon Sep 17 00:00:00 2001 From: cibernox Date: Thu, 11 Jan 2018 23:39:21 +0100 Subject: [PATCH 1/2] Make it a noop in Ember > 3.0.0-beta.2 --- index.js | 18 +++++++++++++++++- package.json | 3 ++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 14578d5..50deb17 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,21 @@ 'use strict'; +let VersionChecker = require('ember-cli-version-checker'); + module.exports = { - name: 'ember-native-dom-event-dispatcher' + name: 'ember-native-dom-event-dispatcher', + init() { + this._super && this._super.init.apply(this, arguments); + + let checker = new VersionChecker(this); + this._shouldDisable = checker.forEmber().gt('3.0.0-beta.2'); + }, + + treeFor() { + if (this._shouldDisable) { + return null; + } + + return this._super.treeFor.apply(this, arguments); + } }; diff --git a/package.json b/package.json index 2126d95..33e09bc 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,8 @@ "ember-addon" ], "dependencies": { - "ember-cli-babel": "^6.11.0" + "ember-cli-babel": "^6.11.0", + "ember-cli-version-checker": "^2.1.0" }, "ember-addon": { "configPath": "tests/dummy/config" From e931a2895bc382874d28147082b238e521196eda Mon Sep 17 00:00:00 2001 From: cibernox Date: Fri, 12 Jan 2018 00:00:45 +0100 Subject: [PATCH 2/2] Print warning to stop using this addon in Ember 3.0 --- index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 50deb17..6677e40 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,7 @@ 'use strict'; let VersionChecker = require('ember-cli-version-checker'); +let hasBeenWarned = false; module.exports = { name: 'ember-native-dom-event-dispatcher', @@ -8,7 +9,14 @@ module.exports = { this._super && this._super.init.apply(this, arguments); let checker = new VersionChecker(this); - this._shouldDisable = checker.forEmber().gt('3.0.0-beta.2'); + + this._shouldDisable = true; + if (checker.forEmber().lt('3.0.0-beta.2')) { + this._shouldDisable = false; + } else if (this.parent === this.project && !process.env.EMBER_TRY_CURRENT_SCENARIO && !hasBeenWarned) { + this.ui.writeWarnLine('ember-native-dom-event-dispatcher is not required for Ember 3.0.0-beta.2 and later, please remove from your `package.json`.'); + hasBeenWarned = true; + } }, treeFor() {