diff options
author | Kevin (Kun) "Kassimo" Qian <kevinkassimo@gmail.com> | 2019-11-26 00:40:57 -0800 |
---|---|---|
committer | Ry Dahl <ry@tinyclouds.org> | 2019-11-26 00:40:57 -0800 |
commit | f88dc4e197f36842b13843dd88da3d74d67578e5 (patch) | |
tree | b74a0da664bf0c126c345efa73815ea96db0b70b /cli/js/realpath.ts | |
parent | 658ec2aaf9c7e0d0b4ded4e97a3d89dc2fa25806 (diff) |
Add Deno.realpath (#3404)
Diffstat (limited to 'cli/js/realpath.ts')
-rw-r--r-- | cli/js/realpath.ts | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/cli/js/realpath.ts b/cli/js/realpath.ts new file mode 100644 index 000000000..c17a0f564 --- /dev/null +++ b/cli/js/realpath.ts @@ -0,0 +1,19 @@ +// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. +import { sendSync, sendAsync } from "./dispatch_json.ts"; +import * as dispatch from "./dispatch.ts"; + +/** Returns absolute normalized path with symbolic links resolved synchronously. + * + * const realPath = Deno.realpathSync("./some/path"); + */ +export function realpathSync(path: string): string { + return sendSync(dispatch.OP_REALPATH, { path }); +} + +/** Returns absolute normalized path with symbolic links resolved. + * + * const realPath = await Deno.realpath("./some/path"); + */ +export async function realpath(path: string): Promise<string> { + return await sendAsync(dispatch.OP_REALPATH, { path }); +} |