forked from san650/ember-cli-page-object
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
79 lines (66 loc) · 1.99 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
70
71
72
73
74
75
76
77
78
79
'use strict';
module.exports = {
name: require('./package').name,
options: {
nodeAssets: {
ceibo: {
vendor: ['index.js']
},
jquery: {
vendor: ['dist/jquery.js'],
destDir: 'ecpo-jquery'
}
}
},
included() {
this.app = this._findHost();
this.import('vendor/ceibo/index.js', { type: 'test' });
if (!this.project.findAddonByName('@ember/jquery') && !this.app.vendorFiles['jquery.js']) {
this.import('vendor/ecpo-jquery/dist/jquery.js', { type: 'test' });
this.import('vendor/shims/ecpo-jquery.js', { type: 'test' });
} else {
this.import('vendor/shims/project-jquery.js', { type: 'test' });
}
this._super.included.apply(this, arguments);
},
treeForAddonTestSupport(tree) {
const testSupportTree = this._super(tree);
const mergeTrees = require('broccoli-merge-trees');
const writeFile = require('broccoli-file-creator');
// Generate re-exports for public modules to allow
// import w/o "test-support/" part in the path:
//
// `import { clickable } from 'ember-cli-page-object';`
//
// instead of:
//
// `import { clickable } from 'ember-cli-page-object/test-support';`
//
// which is a default behavior in ember-cli
const reexportsTree = mergeTrees([
'index',
'extend',
'macros',
'-private/execution_context' // @see: https://github.com/san650/ember-cli-page-object/pull/400#issuecomment-384021927
].map(publicModuleName =>
writeFile(
`/${this.moduleName()}/${publicModuleName}.js`,
`export * from '${this.moduleName()}/test-support/${publicModuleName}';`
)
));
return mergeTrees([
testSupportTree,
this.preprocessJs(
reexportsTree, '/', this.name, { registry: this.registry, }
)
]);
},
_findHost() {
let current = this;
let app;
do {
app = current.app || app;
} while (current.parent.parent && (current = current.parent));
return app;
}
};