-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.js
68 lines (51 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
59
60
61
62
63
64
65
66
67
68
'use strict';
const writeFile = require('broccoli-file-creator');
const mergeTrees = require('broccoli-merge-trees');
const dummyFiles = require('./utils/dummy-files');
let filesTree = [];
module.exports = {
name: require('./package').name,
addonOptions: {},
included() {
let app;
// If the addon has the _findHost() method (in ember-cli >= 2.7.0), we'll just
// use that.
if (typeof this._findHost === 'function') {
app = this._findHost();
} else {
// Otherwise, we'll use this implementation borrowed from the _findHost()
// method in ember-cli.
let current = this;
do {
app = current.app || app;
} while (current.parent.parent && (current = current.parent));
}
this.app = app;
this.addonOptions = this.app.project.config(app.env)['ember-accessibility'] || {};
if (this.addonOptions.isEnabled) {
this.app.import('vendor/style.css');
}
this._super.included.apply(this, arguments);
},
treeForApp(tree) {
if (!this.addonOptions.isEnabled) {
for (let file in dummyFiles) {
filesTree.push(writeFile(file, dummyFiles[file]));
}
return mergeTrees(filesTree);
}
return this._super.treeForApp.call(this, tree);
},
treeForAddon(tree) {
if (!this.addonOptions.isEnabled) {
return;
}
return this._super.treeForAddon.call(this, tree);
},
treeForAddonTestSupport(tree) {
if (!this.addonOptions.isEnabled) {
return writeFile('test-support/audit.js', '');
}
return this._super.treeForAddonTestSupport.call(this, tree);
}
};