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