-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
32 lines (27 loc) · 797 Bytes
/
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
'use strict';
const CommentDefeatureFilter = require('./lib/comment-defeature-filter');
module.exports = {
name: 'ember-cli-comment-defeature',
included(app) {
this._super.included.apply(this, arguments);
this.options = generateOptions(app.options.commentDefeature || {});
},
preprocessTree(type, tree) {
switch (type) {
case 'js':
case 'css':
case 'template':
return new CommentDefeatureFilter(tree, this.options);
}
return tree;
}
};
function generateOptions(options) {
if (options.extensions && !Array.isArray(options.extensions)) {
throw new Error ('`commentDefeature.extensions` must be an array of file extensions');
}
return Object.assign({
features: {},
extensions: ['js', 'hbs', 'css', 'scss']
}, options);
}