Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use configPath to locate the configuration file, instead of assuming a fixed path #797

Merged
merged 1 commit into from
Apr 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions packages/compat/src/compat-adapters/ember-get-config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import V1Addon from '../v1-addon';
import writeFile from 'broccoli-file-creator';
import { join } from 'path';

function createIndexContents(config: any): string {
return `export default ${JSON.stringify(config)};`;
Expand All @@ -19,9 +18,8 @@ function createIndexContents(config: any): string {
*/
export default class extends V1Addon {
get v2Tree() {
const configModulePath = join(this.app.root, 'config/environment.js');
// eslint-disable-next-line @typescript-eslint/no-require-imports
const configModule = require(configModulePath);
const configModule = require(this.app.configPath());
const appEnvironmentConfig = configModule(this.app.env);

return writeFile('index.js', createIndexContents(appEnvironmentConfig));
Expand Down
6 changes: 5 additions & 1 deletion packages/compat/src/v1-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,12 @@ export default class V1App {
return this.app.tests || false;
}

configPath(): string {
return this.app.project.configPath();
}

private get configTree() {
return new this.configLoader(dirname(this.app.project.configPath()), {
return new this.configLoader(dirname(this.configPath()), {
env: this.app.env,
tests: this.app.tests || false,
project: this.app.project,
Expand Down