Skip to content

Commit be9cc39

Browse files
ldt1996kriszyp
authored andcommitted
support tilde paths in config validation
1 parent 57cdd24 commit be9cc39

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

validation/configValidator.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,16 @@ function doesPathExist(pathToCheck) {
226226
}
227227

228228
function validatePath(value, helpers) {
229-
Joi.assert(value, string.pattern(/^[\\/]$|([\\/a-zA-Z_0-9:-]+)+$/, 'directory path'));
229+
Joi.assert(value, string.pattern(/^[\\/~]$|([\\/~a-zA-Z_0-9:-]+)+$/, 'directory path'));
230230

231-
const resolvedValue = path.isAbsolute(value) ? value : path.join(hdbRoot, value);
231+
let resolvedValue;
232+
if (value.startsWith('~/')) {
233+
resolvedValue = path.join(os.homedir(), value.slice(1));
234+
} else if (path.isAbsolute(value)) {
235+
resolvedValue = value;
236+
} else {
237+
resolvedValue = path.join(hdbRoot, value);
238+
}
232239
const doesExistMsg = doesPathExist(resolvedValue);
233240
if (doesExistMsg) {
234241
return helpers.message(doesExistMsg);

0 commit comments

Comments
 (0)