forked from andybluntish/ember-cli-replace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
32 lines (25 loc) · 744 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'
var replace = require('broccoli-replace')
module.exports = {
name: require('./package').name,
included: function() {
this._super.included.apply(this, arguments)
this.app.options.replace = this.app.options.replace || {}
var defaultOptions = {
files: [],
patterns: [],
enabled: true,
}
for (var option in defaultOptions) {
if (!this.app.options.replace.hasOwnProperty(option)) {
this.app.options.replace[option] = defaultOptions[option]
}
}
},
postprocessTree: function(type, tree) {
if (type === 'all' && this.app.options.replace && this.app.options.replace.enabled) {
tree = replace(tree, this.app.options.replace)
}
return tree
},
}