-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
62 lines (52 loc) · 1.95 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
'use strict';
const path = require('path');
const MergeTrees = require('broccoli-merge-trees');
const Funnel = require('broccoli-funnel');
module.exports = {
name: 'nypr-publisher-lib',
included: function(app, parentAddon) {
let target = parentAddon || app;
while(target.app) {
target = target.app;
}
this.app = target;
this.addonConfig = this.app.project.config(this.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()) {//only in dev and test
let mirageFolderName = 'mirage-support';
let mirageOptions = this.app.options[mirageFolderName];
let isDummyApp = this.app.name === 'dummy';
if (isDummyApp || mirageOptions) {//only if options['mirage-support'] in config
if (isDummyApp || mirageOptions.includeAll) {//only if options['mirage-support'].includeAll = true
trees.push(new Funnel(this.mirageSupportDirectory, {
destDir: 'mirage',
exclude: mirageOptions && mirageOptions.exclude || []
}));
} else if (mirageOptions.include) {//else add in options['mirage-support'].include the files needed
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
},
isDevelopingAddon: function() {
return true;
}
};