From 33d6f4c7dea31896722e44b503d42617a0294cab Mon Sep 17 00:00:00 2001 From: Vince Date: Sat, 27 Mar 2021 21:42:45 +0100 Subject: [PATCH] Allow to overwrite projectPath via options --- core/util/makeConfig.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/core/util/makeConfig.js b/core/util/makeConfig.js index 4c8f6a104..15fac0213 100644 --- a/core/util/makeConfig.js +++ b/core/util/makeConfig.js @@ -1,10 +1,14 @@ -var path = require('path'); -var extendConfig = require('./extendConfig'); +const path = require('path'); +const extendConfig = require('./extendConfig'); const NON_CONFIG_COMMANDS = ['init', 'version', 'stop']; function projectPath (config) { - return process.cwd(); + if (config && config.args && typeof config.args.projectPath === 'string' && config.args.projectPath.length > 0) { + return config.args.projectPath; + } else { + return process.cwd(); + } } function loadProjectConfig (command, options, config) { @@ -51,15 +55,14 @@ function loadProjectConfig (command, options, config) { } function makeConfig (command, options) { - var config = {}; + const config = {}; config.args = options || {}; - config.backstop = path.join(__dirname, '../..'); config.projectPath = projectPath(config); config.perf = {}; - var userConfig = Object.assign({}, loadProjectConfig(command, options, config)); + const userConfig = Object.assign({}, loadProjectConfig(command, options, config)); return extendConfig(config, userConfig); }