fix for isFile on Windows with weird symlink things in the WindowsApps folder
This commit is contained in:
Родитель
22a666ac26
Коммит
c0618cbc9f
|
@ -46,7 +46,7 @@ export function filePath(path: string | Buffer | Url | URL): string {
|
|||
path = path.toString();
|
||||
return path.startsWith('file:///') ? fileURLToPath(path) : path;
|
||||
}
|
||||
export const exists: (path: string | Buffer) => Promise<boolean> = path => new Promise<boolean>((r, j) => fs.stat(filePath(path), (err: NodeJS.ErrnoException | null, stats: fs.Stats) => err ? r(false) : r(true)));
|
||||
export const exists = promisify(fs.exists);
|
||||
export const readdir: (path: string | Buffer) => Promise<Array<string>> = promisify(fs.readdir);
|
||||
export const close: (fd: number) => Promise<void> = promisify(fs.close);
|
||||
|
||||
|
@ -101,13 +101,10 @@ export async function readBinaryFile(filename: string): Promise<string> {
|
|||
|
||||
export async function isFile(filePath: string): Promise<boolean> {
|
||||
try {
|
||||
if (await exists(filePath)) {
|
||||
return !(await lstat(filePath)).isDirectory();
|
||||
}
|
||||
return await exists(filePath) && !await isDirectory(filePath);
|
||||
} catch (e) {
|
||||
// don't throw!
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,8 @@
|
|||
"@typescript-eslint/eslint-plugin": "~2.0.0",
|
||||
"@typescript-eslint/parser": "~2.0.0",
|
||||
"eslint": "~6.2.2",
|
||||
"typescript": "~3.6.2"
|
||||
"typescript": "~3.6.2",
|
||||
"source-map-support": "~0.5.13"
|
||||
},
|
||||
"dependencies": {
|
||||
"@azure-tools/async-io": "~3.0.0",
|
||||
|
|
Загрузка…
Ссылка в новой задаче