Skip to content

Commit b9e3887

Browse files
committed
Update the environment.ts
1 parent 61a9c38 commit b9e3887

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<% if (notMinimal) { %>
2+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
3+
// @ts-expect-error
4+
import { getGlobalConfig } from '@embroider/macros/src/addon/runtime';
5+
<% } %>
6+
7+
interface Config {
8+
isTesting?: boolean;
9+
environment: string;
10+
modulePrefix: string;
11+
podModulePrefix?: string;
12+
locationType: 'history' | 'hash' | 'none' | 'auto';
13+
rootURL: string;
14+
EmberENV?: Record<string, unknown>;
15+
APP: Record<string, unknown> & { rootElement?: string; autoboot?: boolean };
16+
}
17+
18+
const ENV: Config = {
19+
modulePrefix: '<%= name %>',
20+
environment: import.meta.env.DEV ? 'development' : 'production',
21+
rootURL: '/',
22+
locationType: 'history',
23+
EmberENV: {},
24+
APP: {},
25+
};
26+
27+
export default ENV;
28+
29+
<% if (notMinimal) { %>
30+
export function enterTestMode() {
31+
ENV.locationType = 'none';
32+
ENV.APP.rootElement = '#ember-testing';
33+
ENV.APP.autoboot = false;
34+
35+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
36+
const config = getGlobalConfig()['@embroider/macros'];
37+
38+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
39+
if (config) config.isTesting = true;
40+
}
41+
<% } %>

index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@ function stringifyAndNormalize(contents) {
2424
* (see `conditional-files`)
2525
*/
2626
const replacers = {
27+
'app/config/environment.ts'(locals, contents) {
28+
if (locals.noCompat) {
29+
let filePath = join(
30+
CONDITIONAL_FILES,
31+
'no-compat',
32+
'app/config/environment.ts',
33+
);
34+
let raw = readFileSync(filePath).toString();
35+
return ejs.render(raw, locals);
36+
}
37+
38+
return contents;
39+
},
2740
'package.json'(...args) {
2841
return this.updatePackageJson(...args);
2942
},

0 commit comments

Comments
 (0)