-
Notifications
You must be signed in to change notification settings - Fork 38
/
index.js
56 lines (45 loc) · 1.6 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
/* eslint-env node */
'use strict';
const path = require('path');
const MergeTrees = require('broccoli-merge-trees');
const Funnel = require('broccoli-funnel');
module.exports = {
name: 'ember-data-github',
included(app) {
this.addonConfig = this.app.project.config(app.env)['ember-cli-mirage'] || {};
this.mirageSupportDirectory = path.join(this.root, 'mirage-support');
this._super.included.apply(this, arguments);
},
treeForApp(appTree) {
var trees = [appTree];
if (this._shouldIncludeMirageFiles()) {
let mirageFolderName = 'mirage-support';
let mirageOptions = this.app.options[mirageFolderName];
let isDummyApp = this.app.name === 'dummy';
if (isDummyApp || mirageOptions) {
if (isDummyApp || mirageOptions.includeAll) {
trees.push(new Funnel(this.mirageSupportDirectory, {
destDir: 'mirage',
exclude: mirageOptions && mirageOptions.exclude || []
}));
} else if (mirageOptions.include) {
trees.push(new Funnel(this.mirageSupportDirectory, {
destDir: 'mirage',
include: mirageOptions.include
}));
}
}
}
return new MergeTrees(trees, {
overwrite: true
});
},
_shouldIncludeMirageFiles() {
if (process.env.EMBER_CLI_FASTBOOT) {
return false;
}
let enabledInProd = this.app.env === 'production' && this.addonConfig.enabled,
explicitExcludeFiles = this.addonConfig.excludeFilesFromBuild;
return enabledInProd || (this.app.env !== 'production' && explicitExcludeFiles !== true);//eslint-disable-line
}
};