1 |
|
2 | 'use strict';
|
3 |
|
4 | module.exports = {
|
5 | name: 'ember-cli-page-object',
|
6 |
|
7 | options: {
|
8 | nodeAssets: {
|
9 | ceibo: function() {
|
10 | return {
|
11 | enabled: this._shouldIncludeFiles(),
|
12 | import: ['index.js']
|
13 | };
|
14 | },
|
15 | jquery: function() {
|
16 | return {
|
17 | enabled: this._shouldIncludeFiles(),
|
18 | vendor: ['dist/jquery.js'],
|
19 | destDir: 'ecpo-jquery'
|
20 | }
|
21 | }
|
22 | }
|
23 | },
|
24 |
|
25 | included: function() {
|
26 | this.app = this._findHost();
|
27 |
|
28 | if (this._shouldIncludeFiles()) {
|
29 | if (!this.app.vendorFiles['jquery.js']) {
|
30 | this.import('vendor/ecpo-jquery/dist/jquery.js');
|
31 | this.import('vendor/shims/ecpo-jquery.js');
|
32 | } else {
|
33 | this.import('vendor/shims/project-jquery.js');
|
34 | }
|
35 | }
|
36 |
|
37 | this._super.included.apply(this, arguments);
|
38 | },
|
39 |
|
40 | treeFor: function(/*name*/) {
|
41 | if (!this._shouldIncludeFiles()) {
|
42 | return;
|
43 | }
|
44 |
|
45 | return this._super.treeFor.apply(this, arguments);
|
46 | },
|
47 |
|
48 | _shouldIncludeFiles: function() {
|
49 |
|
50 |
|
51 |
|
52 |
|
53 | if(process.env && process.env.EMBER_CLI_FASTBOOT) {
|
54 | return false;
|
55 | } else {
|
56 | return this.app.env !== 'production';
|
57 | }
|
58 | },
|
59 |
|
60 | _findHost() {
|
61 | let current = this;
|
62 | let app;
|
63 |
|
64 | do {
|
65 | app = current.app || app;
|
66 | } while (current.parent.parent && (current = current.parent));
|
67 |
|
68 | return app;
|
69 | }
|
70 | };
|