2019-03-12 01:14:26 +08:00
|
|
|
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
2019-03-14 15:24:54 +01:00
|
|
|
|
|
|
|
/** Test whether or not the given path exists by checking with the file system */
|
2019-03-12 01:14:26 +08:00
|
|
|
export async function exists(filePath: string): Promise<boolean> {
|
2019-03-19 00:34:54 +08:00
|
|
|
return Deno.lstat(filePath)
|
2019-04-24 13:41:23 +02:00
|
|
|
.then((): boolean => true)
|
|
|
|
.catch((): boolean => false);
|
2019-03-12 01:14:26 +08:00
|
|
|
}
|
|
|
|
|
2019-03-14 15:24:54 +01:00
|
|
|
/** Test whether or not the given path exists by checking with the file system */
|
2019-03-12 01:14:26 +08:00
|
|
|
export function existsSync(filePath: string): boolean {
|
|
|
|
try {
|
2019-03-19 00:34:54 +08:00
|
|
|
Deno.lstatSync(filePath);
|
2019-03-12 01:14:26 +08:00
|
|
|
return true;
|
|
|
|
} catch {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|