fix backslash breaking path selection
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Timo Hocker 2020-07-24 08:18:36 +02:00
parent 7521fb310c
commit 6207de8e5b
3 changed files with 7 additions and 3469 deletions

View File

@ -20,14 +20,16 @@ export class PathType extends TypeValidation {
public async to_type (value: unknown): Promise<unknown> {
if (typeof value !== 'string')
throw new Error (`invalid type for ${this.option_type}`);
if (!await fs.pathExists (value))
const escaped = value.replace (/\\$/u, '');
if (!await fs.pathExists (escaped))
throw new Error ('path does not exist');
if (this.option_type === 'path')
return value;
return escaped;
const stat = await fs.stat (value);
const stat = await fs.stat (escaped);
if (stat.isDirectory () === (this.option_type === 'folder'))
return value;
return escaped;
throw new Error ('cannot assign folder to file');
}

View File

@ -1,6 +1,6 @@
{
"name": "@sapphirecode/console-app",
"version": "2.1.2",
"version": "2.1.3",
"main": "dist/lib/index.js",
"author": {
"name": "Timo Hocker",

File diff suppressed because it is too large Load Diff