-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
71 lines (54 loc) · 1.57 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
63
64
65
66
67
68
69
70
71
'use strict';
const funnel = require('broccoli-funnel');
const SilentError = require('silent-error');
const { inspect } = require('util');
module.exports = {
name: require('./package').name,
options: {
'@embroider/macros': {
setOwnConfig: {},
},
},
included(parent) {
this._super.included.apply(this, arguments);
let env = this.app.env;
let isDebug = !this.app.isProduction;
let isTesting = this.app.tests;
this.options['@embroider/macros'].setOwnConfig.env = env;
if (parent !== this.app) {
return;
}
let exclude = [];
if (!isDebug) {
exclude.push('**/-debug.{js,ts,d.ts}');
}
if (!isTesting) {
exclude.push('**/-testing.{js,ts,d.ts}');
}
if (env !== 'development') {
exclude.push('**/-development.{js,ts,d.ts}');
}
if (env !== 'test') {
exclude.push('**/-test.{js,ts,d.ts}');
}
if (env !== 'production') {
exclude.push('**/-production.{js,ts,d.ts}');
}
let userExcludes = this.app.options.services?.exclude ?? [];
if (
!Array.isArray(userExcludes) ||
!userExcludes.every((glob) => typeof glob === 'string')
) {
throw new SilentError(
'Invalid config in ember-cli-build.js: ' +
'services.exclude must be an array of glob patterns. ' +
`Found ${inspect(userExcludes)} instead.`
);
}
exclude.push(...userExcludes);
this.app.trees.app = funnel(this.app.trees.app, {
annotation: 'ember-swappable-service',
exclude: exclude.map((glob) => `services/${glob}`),
});
},
};