Skip to content

Commit 4fc7595

Browse files
committed
fix(ember): provide default config path
When including this addon inside an Ember “app”, `app.options.configPath` is not defined. This file is, under almost all but the most unusual circumstances, this file will be located at `config/environment` relative to the project root. By providing that as a default to fall back on in the case that the configuration option is not provided, including this addon inside an Ember app works again!
1 parent 2097045 commit 4fc7595

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/ember/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
const fs = require('fs');
33
const { resolve } = require('path');
44

5+
const DEFAULT_CONFIG_PATH = 'config/environment';
6+
57
function readSnippet(fileName) {
68
return `<script>${fs.readFileSync(`${__dirname}/vendor/${fileName}`, 'utf8')}</script>`;
79
}
@@ -20,7 +22,8 @@ module.exports = {
2022
getAddonConfig(app) {
2123
let config = {};
2224
try {
23-
const fullConfigPath = resolve(app.project.root, app.options.configPath);
25+
const configPath = app.options.configPath || DEFAULT_CONFIG_PATH;
26+
const fullConfigPath = resolve(app.project.root, configPath);
2427
config = require(fullConfigPath)(app.env);
2528
} catch(_) {
2629
// Config not found

0 commit comments

Comments
 (0)