summaryrefslogtreecommitdiff
path: root/cli/js/ops/fs/read_link.ts
blob: b5ac82cd7eebe4da2c413f3f3ef13dc0b263bfb5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { sendSync, sendAsync } from "../dispatch_json.ts";

/** Returns the destination of the named symbolic link.
 *
 *       const targetPath = Deno.readlinkSync("symlink/path");
 *
 * Requires `allow-read` permission. */
export function readlinkSync(path: string): string {
  return sendSync("op_read_link", { path });
}

/** Resolves to the destination of the named symbolic link.
 *
 *       const targetPath = await Deno.readlink("symlink/path");
 *
 * Requires `allow-read` permission. */
export async function readlink(path: string): Promise<string> {
  return await sendAsync("op_read_link", { path });
}