Skip to content

Commit ab2e7ff

Browse files
aspeardpopp07
authored andcommitted
fix: alllow absolute filepaths to be passed to --config
It turns out that the findUp method cannot handle a full path to a file as input. When this is passed in, it redudantly or completely incorrectly prepends the current working directory to the front of the returned path. Work around is to split any path information off of the input path and pass the path portion into the method as opt.cwd.
1 parent 26402c4 commit ab2e7ff

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/cli-validator/utils/processConfiguration.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,23 @@ const validateConfigObject = function(configObject, chalk) {
171171
const getConfigObject = async function(defaultMode, chalk, configFileOverride) {
172172
let configObject;
173173

174-
// if user explicitly provided a config file, use it instead of .validaterc
175-
const configFileName = configFileOverride || '.validaterc';
174+
const findUpOpts = {};
175+
let configFileName;
176+
177+
// You cannot pass a full path into findUp as a file name, you must split the
178+
// path or else findUp redudantly prepends the path to the result.
179+
if (configFileOverride) {
180+
configFileName = path.basename(configFileOverride);
181+
findUpOpts.cwd = path.dirname(configFileOverride);
182+
} else {
183+
configFileName = '.validaterc';
184+
}
176185

177186
// search up the file system for the first instance
178187
// of '.validaterc' or,
179188
// if a config file override is passed in, use find-up
180189
// to verify existence of the file
181-
const configFile = await findUp(configFileName);
190+
const configFile = await findUp(configFileName, findUpOpts);
182191

183192
// if the user does not have a config file, run in default mode and warn them
184193
// (findUp returns null if it does not find a file)

0 commit comments

Comments
 (0)