-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathindex.js
More file actions
47 lines (39 loc) · 1.13 KB
/
index.js
File metadata and controls
47 lines (39 loc) · 1.13 KB
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
'use strict';
var lazyLoaded = {};
function lazyLoad(moduleName){
if (!lazyLoaded[moduleName]) {
lazyLoaded[moduleName] = require(moduleName);
}
return lazyLoaded[moduleName];
}
module.exports = {
name: 'ember-cli-fake-server',
treeFor: function() {
if (this._shouldIncludeFiles()) {
return this._super.treeFor.apply(this, arguments);
}
return this._emptyTree();
},
postprocessTree: function(type, tree) {
if (type === 'js' && !this._shouldIncludeFiles()) {
return this._excludeSelf(tree);
}
return tree;
},
_excludeSelf: function(tree){
var modulePrefix = this.app.project.config(this.app.env)['modulePrefix'];
var Funnel = lazyLoad('broccoli-funnel');
return new Funnel(tree, {
exclude: [new RegExp('^' + modulePrefix + '/ember-cli-fake-server/')],
description: 'Funnel: exclude ember-cli-fake-server'
});
},
_emptyTree: function(){
var mergeTrees = lazyLoad('broccoli-merge-trees');
return mergeTrees([]);
},
_shouldIncludeFiles: function(){
if (process.env.EMBER_CLI_FASTBOOT) { return false; }
return this.app.env !== 'production';
}
};