fix backslash breaking path selection
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
7521fb310c
commit
6207de8e5b
@ -20,14 +20,16 @@ export class PathType extends TypeValidation {
|
|||||||
public async to_type (value: unknown): Promise<unknown> {
|
public async to_type (value: unknown): Promise<unknown> {
|
||||||
if (typeof value !== 'string')
|
if (typeof value !== 'string')
|
||||||
throw new Error (`invalid type for ${this.option_type}`);
|
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');
|
throw new Error ('path does not exist');
|
||||||
if (this.option_type === 'path')
|
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'))
|
if (stat.isDirectory () === (this.option_type === 'folder'))
|
||||||
return value;
|
return escaped;
|
||||||
|
|
||||||
throw new Error ('cannot assign folder to file');
|
throw new Error ('cannot assign folder to file');
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@sapphirecode/console-app",
|
"name": "@sapphirecode/console-app",
|
||||||
"version": "2.1.2",
|
"version": "2.1.3",
|
||||||
"main": "dist/lib/index.js",
|
"main": "dist/lib/index.js",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Timo Hocker",
|
"name": "Timo Hocker",
|
||||||
|
3464
yarn-error.log
3464
yarn-error.log
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user