Skip to content

Commit

Permalink
Use the current working directory's config file.
Browse files Browse the repository at this point in the history
Instead of loading the configuration using a relative path from
core/, load it from the current working directory.

This means that a Bedrock command should be called necessarily from a
project root directory (where the config is supposed to live), but I
guess this was already the case when using commands defined in the
Gulpfile or in the package.json file.

In other words, this change shouldn't have an impact on existing
installs, but paves the road to allow calling Bedrock from projects that
don't have the full source code of Bedrock within their own directory,
and provide their own configuration files.

See #320 for details.
  • Loading branch information
thusc committed Jul 14, 2021
1 parent a098863 commit 385497f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions core/discovery/config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
const path = require('path');

const defaultConfig = require('./default-config');

let config = {...defaultConfig};

try {
const projectConfig = require('../../bedrock.config');
const projectConfigPath = path.join(process.cwd(), 'bedrock.config');
const projectConfig = require(projectConfigPath);
config = {...config, ...projectConfig};
} catch (err) {
console.log(err);
Expand All @@ -13,7 +16,8 @@ try {

if (process.env.NODE_ENV == "production") {
try {
const projectConfig = require('../../bedrock.config.prod');
const projectConfigPath = path.join(process.cwd(), 'bedrock.config.prod');
const projectConfig = require(projectConfigPath);
config = {...config, ...projectConfig};
} catch (err) {
console.log(err);
Expand Down

0 comments on commit 385497f

Please sign in to comment.