summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/dts/lib.deno.ns.d.ts4
-rw-r--r--cli/tests/unit/real_path_test.ts17
2 files changed, 19 insertions, 2 deletions
diff --git a/cli/dts/lib.deno.ns.d.ts b/cli/dts/lib.deno.ns.d.ts
index 6b4e75bfa..ddbb890b7 100644
--- a/cli/dts/lib.deno.ns.d.ts
+++ b/cli/dts/lib.deno.ns.d.ts
@@ -1467,7 +1467,7 @@ declare namespace Deno {
* Requires `allow-read` permission for the target path.
* Also requires `allow-read` permission for the CWD if the target path is
* relative.*/
- export function realPathSync(path: string): string;
+ export function realPathSync(path: string | URL): string;
/** Resolves to the absolute normalized path, with symbolic links resolved.
*
@@ -1483,7 +1483,7 @@ declare namespace Deno {
* Requires `allow-read` permission for the target path.
* Also requires `allow-read` permission for the CWD if the target path is
* relative.*/
- export function realPath(path: string): Promise<string>;
+ export function realPath(path: string | URL): Promise<string>;
export interface DirEntry {
name: string;
diff --git a/cli/tests/unit/real_path_test.ts b/cli/tests/unit/real_path_test.ts
index fce28d80b..10e060578 100644
--- a/cli/tests/unit/real_path_test.ts
+++ b/cli/tests/unit/real_path_test.ts
@@ -1,9 +1,11 @@
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
import {
assert,
+ assertEquals,
assertMatch,
assertThrows,
assertThrowsAsync,
+ pathToAbsoluteFileUrl,
unitTest,
} from "./test_util.ts";
@@ -19,6 +21,12 @@ unitTest({ perms: { read: true } }, function realPathSyncSuccess(): void {
}
});
+unitTest({ perms: { read: true } }, function realPathSyncUrl(): void {
+ const relative = "cli/tests/fixture.json";
+ const url = pathToAbsoluteFileUrl(relative);
+ assertEquals(Deno.realPathSync(relative), Deno.realPathSync(url));
+});
+
unitTest(
{
perms: { read: true, write: true },
@@ -67,6 +75,15 @@ unitTest({ perms: { read: true } }, async function realPathSuccess(): Promise<
});
unitTest(
+ { perms: { read: true } },
+ async function realPathUrl(): Promise<void> {
+ const relative = "cli/tests/fixture.json";
+ const url = pathToAbsoluteFileUrl(relative);
+ assertEquals(await Deno.realPath(relative), await Deno.realPath(url));
+ },
+);
+
+unitTest(
{
perms: { read: true, write: true },
},