-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
76 lines (59 loc) · 1.55 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
'use strict';
const Funnel = require('broccoli-funnel');
module.exports = {
name: 'ember-cli-funnel',
included(app) {
this.app = app;
this._initOptions();
this._injectFunnel();
},
_initOptions() {
let defaultOptions = {
enabled: this.app.env === 'production',
exclude: []
};
this.options = this.app.options.funnel || {};
for (let option in defaultOptions) {
if (!this.options.hasOwnProperty(option)) {
this.options[option] = defaultOptions[option];
}
}
},
_injectFunnel() {
if (!this.options.enabled) {
return;
}
let { options } = this;
let { appAndDependencies } = this.app;
this.app.appAndDependencies = function() {
let tree = appAndDependencies.apply(this, arguments);
tree = new Funnel(tree, {
exclude: options.exclude,
description: 'Funnel (appAndDependencies): ' + this.name
});
return tree;
};
let { _processedTestsTree } = this.app;
this.app._processedTestsTree = function() {
let tree = _processedTestsTree.apply(this, arguments);
tree = new Funnel(tree, {
exclude: options.exclude,
description: 'Funnel (_processedTestsTree): ' + this.name
});
return tree;
};
},
preprocessTree(type, tree) {
if (!this.options.enabled) {
return tree;
}
let { options } = this;
if (type === 'css') {
tree = new Funnel(tree, {
exclude: options.exclude,
description: 'Funnel (css): ' + this.name
});
}
return tree;
}
};