diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2020-05-04 14:23:06 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-04 14:23:06 -0400 |
commit | 6c02b061ce157b9fc3d20f9bcace0bc6638290d3 (patch) | |
tree | 811310674a76ee8ce5761cec3ee711012e542fcf /cli/js | |
parent | 191c59a5912121fb9062aff6a08b1cc110674044 (diff) |
stabilize Deno.cwd and require --allow-read (#5068)
Diffstat (limited to 'cli/js')
-rw-r--r-- | cli/js/deno.ts | 2 | ||||
-rw-r--r-- | cli/js/deno_unstable.ts | 1 | ||||
-rw-r--r-- | cli/js/lib.deno.ns.d.ts | 14 | ||||
-rw-r--r-- | cli/js/lib.deno.unstable.d.ts | 15 | ||||
-rw-r--r-- | cli/js/tests/dir_test.ts | 2 |
5 files changed, 16 insertions, 18 deletions
diff --git a/cli/js/deno.ts b/cli/js/deno.ts index c60ebdae3..38b2f6d2a 100644 --- a/cli/js/deno.ts +++ b/cli/js/deno.ts @@ -19,7 +19,7 @@ export { DiagnosticItem, DiagnosticMessageChain, } from "./diagnostics.ts"; -export { chdir } from "./ops/fs/dir.ts"; +export { chdir, cwd } from "./ops/fs/dir.ts"; export { errors } from "./errors.ts"; export { File, diff --git a/cli/js/deno_unstable.ts b/cli/js/deno_unstable.ts index 1f4baefdc..98e60f665 100644 --- a/cli/js/deno_unstable.ts +++ b/cli/js/deno_unstable.ts @@ -14,7 +14,6 @@ export { setRaw } from "./ops/tty.ts"; export { utimeSync, utime } from "./ops/fs/utime.ts"; export { ShutdownMode, shutdown } from "./net.ts"; export { listen, listenDatagram, connect } from "./net_unstable.ts"; -export { cwd } from "./ops/fs/dir.ts"; export { startTls } from "./tls.ts"; export { kill } from "./ops/process.ts"; export { diff --git a/cli/js/lib.deno.ns.d.ts b/cli/js/lib.deno.ns.d.ts index 45730acbc..6adaf26ef 100644 --- a/cli/js/lib.deno.ns.d.ts +++ b/cli/js/lib.deno.ns.d.ts @@ -144,6 +144,20 @@ declare namespace Deno { */ export function chdir(directory: string): void; + /** + * Return a string representing the current working directory. + * + * If the current directory can be reached via multiple paths (due to symbolic + * links), `cwd()` may return any one of them. + * + * const currentWorkingDirectory = Deno.cwd(); + * + * Throws `Deno.errors.NotFound` if directory not available. + * + * Requires --allow-read + */ + export function cwd(): string; + export enum SeekMode { Start = 0, Current = 1, diff --git a/cli/js/lib.deno.unstable.d.ts b/cli/js/lib.deno.unstable.d.ts index 88b9f002c..a523300cc 100644 --- a/cli/js/lib.deno.unstable.d.ts +++ b/cli/js/lib.deno.unstable.d.ts @@ -1024,21 +1024,6 @@ declare namespace Deno { options: ConnectOptions | UnixConnectOptions ): Promise<Conn>; - /** - * **UNSTABLE**: Currently under evaluation to decide if explicit permission is - * required to get the value of the current working directory. - * - * Return a string representing the current working directory. - * - * If the current directory can be reached via multiple paths (due to symbolic - * links), `cwd()` may return any one of them. - * - * const currentWorkingDirectory = Deno.cwd(); - * - * Throws `Deno.errors.NotFound` if directory not available. - */ - export function cwd(): string; - export interface StartTlsOptions { /** A literal IP address or host name that can be resolved to an IP address. * If not specified, defaults to `127.0.0.1`. */ diff --git a/cli/js/tests/dir_test.ts b/cli/js/tests/dir_test.ts index 3686471f1..dc05d9564 100644 --- a/cli/js/tests/dir_test.ts +++ b/cli/js/tests/dir_test.ts @@ -1,7 +1,7 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. import { unitTest, assert, assertEquals } from "./test_util.ts"; -unitTest(function dirCwdNotNull(): void { +unitTest({ perms: { read: true } }, function dirCwdNotNull(): void { assert(Deno.cwd() != null); }); |