forked from san650/ember-cli-page-object
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
69 lines (57 loc) · 1.52 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
59
60
61
62
63
64
65
66
67
68
69
'use strict';
module.exports = {
name: 'ember-cli-page-object',
options: {
nodeAssets: {
ceibo: function() {
return {
enabled: this._shouldIncludeFiles(),
import: ['index.js']
};
},
jquery: function() {
return {
enabled: this._shouldIncludeFiles(),
vendor: ['dist/jquery.js'],
destDir: 'ecpo-jquery'
}
}
}
},
included: function() {
this.app = this._findHost();
if (this._shouldIncludeFiles()) {
if (!this.app.vendorFiles['jquery.js']) {
this.import('vendor/ecpo-jquery/dist/jquery.js');
this.import('vendor/shims/ecpo-jquery.js');
} else {
this.import('vendor/shims/project-jquery.js');
}
}
this._super.included.apply(this, arguments);
},
treeFor: function(/*name*/) {
if (!this._shouldIncludeFiles()) {
return;
}
return this._super.treeFor.apply(this, arguments);
},
_shouldIncludeFiles: function() {
// TODO: In order to make the addon work in EmberTwiddle, we cannot use // the `tests` prop til
// https://github.com/joostdevries/twiddle-backend/pull/28 is merged.
// return !!this.app.tests;
if(process.env && process.env.EMBER_CLI_FASTBOOT) {
return false;
} else {
return this.app.env !== 'production';
}
},
_findHost() {
let current = this;
let app;
do {
app = current.app || app;
} while (current.parent.parent && (current = current.parent));
return app;
}
};