From 385497f55792f787bd89a0b1f915243251fbbfc8 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Wed, 14 Jul 2021 17:31:04 +0200 Subject: [PATCH] Use the current working directory's config file. 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 https://github.com/usebedrock/bedrock/issues/320 for details. --- core/discovery/config.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/discovery/config.js b/core/discovery/config.js index 215de45..c041b9b 100644 --- a/core/discovery/config.js +++ b/core/discovery/config.js @@ -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); @@ -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);