diff --git a/fs/exists.ts b/fs/exists.ts index 41961a0f23..ce4b83a4cf 100644 --- a/fs/exists.ts +++ b/fs/exists.ts @@ -2,7 +2,7 @@ /** Test whether or not the given path exists by checking with the file system */ export async function exists(filePath: string): Promise { - return Deno.stat(filePath) + return Deno.lstat(filePath) .then(() => true) .catch(() => false); } @@ -10,7 +10,7 @@ export async function exists(filePath: string): Promise { /** Test whether or not the given path exists by checking with the file system */ export function existsSync(filePath: string): boolean { try { - Deno.statSync(filePath); + Deno.lstatSync(filePath); return true; } catch { return false; diff --git a/fs/exists_test.ts b/fs/exists_test.ts index 3d781108e1..1e94c7f691 100644 --- a/fs/exists_test.ts +++ b/fs/exists_test.ts @@ -34,3 +34,13 @@ test(function existsDirectorySync() { ); assertEquals(existsSync(testdataDir), true); }); + +test(function existsLinkSync() { + // TODO(axetroy): generate link file use Deno api instead of set a link file in repository + assertEquals(existsSync(path.join(testdataDir, "0-link.ts")), true); +}); + +test(async function existsLink() { + // TODO(axetroy): generate link file use Deno api instead of set a link file in repository + assertEquals(await exists(path.join(testdataDir, "0-link.ts")), true); +}); diff --git a/fs/testdata/0-link.ts b/fs/testdata/0-link.ts new file mode 120000 index 0000000000..24c6b8053c --- /dev/null +++ b/fs/testdata/0-link.ts @@ -0,0 +1 @@ +./fs/testdata/0.ts \ No newline at end of file