-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
58 lines (43 loc) · 1.58 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* jshint node: true */
'use strict';
module.exports = {
name: 'ember-runtime-enumerable-includes-polyfill',
included: function(app) {
this._super.included.apply(this, arguments);
var importContext;
if (this.import) { // support for ember-cli >= 2.7
importContext = this;
} else { // addon support for ember-cli < 2.7
importContext = this._findHostForLegacyEmberCLI();
}
var emberVersion = this._getEmberVersion();
if (emberVersion && emberVersion.lt('2.8.0-beta.1')) {
importContext.import('vendor/enumerable-includes-polyfill/index.js');
}
},
_getEmberVersion: function() {
var VersionChecker = require('ember-cli-version-checker');
var checker = new VersionChecker(this);
var emberVersionChecker = checker.for('ember-source', 'npm');
if (emberVersionChecker.version) {
return emberVersionChecker;
}
emberVersionChecker = checker.for('ember', 'bower');
if (emberVersionChecker.version) {
return emberVersionChecker;
}
this.ui.writeLine('[ember-runtime-enumerable-includes-polyfill] Cannot identify Ember version to determine if polyfill is needed.');
},
// included from https://git.io/v6F7n
// not needed for ember-cli > 2.7
_findHostForLegacyEmberCLI: function() {
var current = this;
var app;
// Keep iterating upward until we don't have a grandparent.
// Has to do this grandparent check because at some point we hit the project.
do {
app = current.app || app;
} while (current.parent.parent && (current = current.parent));
return app;
}
};