From 6d63391a380976ee4c5577d8efe449afede66f36 Mon Sep 17 00:00:00 2001 From: X Date: Tue, 3 Nov 2020 02:11:42 +0800 Subject: feat(std/node/fs): add realpath and realpathSync (#8169) --- std/node/_fs/_fs_realpath.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 std/node/_fs/_fs_realpath.ts (limited to 'std/node/_fs/_fs_realpath.ts') diff --git a/std/node/_fs/_fs_realpath.ts b/std/node/_fs/_fs_realpath.ts new file mode 100644 index 000000000..586a87cfc --- /dev/null +++ b/std/node/_fs/_fs_realpath.ts @@ -0,0 +1,22 @@ +type Options = { encoding: string }; +type Callback = (err: Error | null, path?: string) => void; + +export function realpath( + path: string, + options?: Options | Callback, + callback?: Callback, +) { + if (typeof options === "function") { + callback = options; + } + if (!callback) { + throw new Error("No callback function supplied"); + } + Deno.realPath(path) + .then((path) => callback!(null, path)) + .catch((err) => callback!(err)); +} + +export function realpathSync(path: string): string { + return Deno.realPathSync(path); +} -- cgit v1.2.3