forked from projectcaluma/ember-caluma
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
54 lines (42 loc) · 1.26 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
"use strict";
const Funnel = require("broccoli-funnel");
const mergeTrees = require("broccoli-merge-trees");
const path = require("path");
/* eslint-disable node/no-unpublished-require */
const EngineAddon = require("ember-engines/lib/engine-addon");
const DEFAULT_OPTIONS = {
includeMirageConfig: true,
};
/* eslint-disable ember/avoid-leaking-state-in-ember-objects */
module.exports = EngineAddon.extend({
name: require("./package.json").name,
lazyLoading: false,
// see https://github.com/dfreeman/ember-cli-node-assets/issues/11
// for why this is not wrapped in `options`
babel: {
plugins: ["@babel/plugin-proposal-object-rest-spread"],
},
included() {
this._super.included.apply(this, arguments);
},
treeForApp(appTree) {
const trees = [appTree];
const app = this._findHost();
const addonOptions = Object.assign(
{},
DEFAULT_OPTIONS,
app.options["ember-caluma"]
);
if (
addonOptions.includeMirageConfig &&
app.registry.availablePlugins["ember-cli-mirage"]
) {
const mirageDir = path.join(__dirname, "addon-mirage-support");
const mirageTree = new Funnel(mirageDir, {
destDir: "mirage",
});
trees.push(mirageTree);
}
return mergeTrees(trees);
},
});