summaryrefslogtreecommitdiff
path: root/cli/js
diff options
context:
space:
mode:
Diffstat (limited to 'cli/js')
-rw-r--r--cli/js/deno.ts2
-rw-r--r--cli/js/file_info.ts4
-rw-r--r--cli/js/lib.deno.ns.d.ts19
-rw-r--r--cli/js/read_dir.ts8
-rw-r--r--cli/js/read_dir_test.ts24
-rw-r--r--cli/js/test_util.ts2
6 files changed, 29 insertions, 30 deletions
diff --git a/cli/js/deno.ts b/cli/js/deno.ts
index ab1144496..92c6984ac 100644
--- a/cli/js/deno.ts
+++ b/cli/js/deno.ts
@@ -111,7 +111,7 @@ export {
ProcessStatus,
Signal
} from "./process.ts";
-export { readDirSync, readDir } from "./read_dir.ts";
+export { readdirSync, readdir } from "./read_dir.ts";
export { readFileSync, readFile } from "./read_file.ts";
export { readlinkSync, readlink } from "./read_link.ts";
export { realpathSync, realpath } from "./realpath.ts";
diff --git a/cli/js/file_info.ts b/cli/js/file_info.ts
index 18f68e0d5..71ecbee89 100644
--- a/cli/js/file_info.ts
+++ b/cli/js/file_info.ts
@@ -3,8 +3,8 @@ import { StatResponse } from "./stat.ts";
import { build } from "./build.ts";
/** A FileInfo describes a file and is returned by `stat`, `lstat`,
- * `statSync`, `lstatSync`. A list of FileInfo is returned by `readDir`,
- * `readDirSync`. */
+ * `statSync`, `lstatSync`. A list of FileInfo is returned by `readdir`,
+ * `readdirSync`. */
export interface FileInfo {
/** The size of the file, in bytes. */
len: number;
diff --git a/cli/js/lib.deno.ns.d.ts b/cli/js/lib.deno.ns.d.ts
index 555a2ebf7..c6318b8ab 100644
--- a/cli/js/lib.deno.ns.d.ts
+++ b/cli/js/lib.deno.ns.d.ts
@@ -992,8 +992,8 @@ declare namespace Deno {
/** UNSTABLE: 'len' maybe should be 'length' or 'size'.
*
* A FileInfo describes a file and is returned by `stat`, `lstat`,
- * `statSync`, `lstatSync`. A list of FileInfo is returned by `readDir`,
- * `readDirSync`. */
+ * `statSync`, `lstatSync`. A list of FileInfo is returned by `readdir`,
+ * `readdirSync`. */
export interface FileInfo {
/** **UNSTABLE**: `.len` maybe should be `.length` or `.size`.
*
@@ -1079,25 +1079,24 @@ declare namespace Deno {
// @url js/read_dir.d.ts
- /** UNSTABLE: Unstable rename to readdirSync.
+ /** UNSTABLE: need to consider streaming case
*
- /* Synchronously reads the directory given by `path` and returns an array of
+ * Synchronously reads the directory given by `path` and returns an array of
* `Deno.FileInfo`.
*
- * const files = Deno.readDirSync("/");
+ * const files = Deno.readdirSync("/");
*
* Requires `allow-read` permission. */
- export function readDirSync(path: string): FileInfo[];
+ export function readdirSync(path: string): FileInfo[];
- /** UNSTABLE: Possibly rename to `.readdir()`. Maybe need to return an
- * `AsyncIterable`.
+ /** UNSTABLE: Maybe need to return an `AsyncIterable`.
*
* Reads the directory given by `path` and resolves to an array of `Deno.FileInfo`.
*
- * const files = await Deno.readDir("/");
+ * const files = await Deno.readdir("/");
*
* Requires `allow-read` permission. */
- export function readDir(path: string): Promise<FileInfo[]>;
+ export function readdir(path: string): Promise<FileInfo[]>;
// @url js/copy_file.d.ts
diff --git a/cli/js/read_dir.ts b/cli/js/read_dir.ts
index 43223e015..d8c1a7db8 100644
--- a/cli/js/read_dir.ts
+++ b/cli/js/read_dir.ts
@@ -18,10 +18,10 @@ function res(response: ReadDirResponse): FileInfo[] {
/** Synchronously reads the directory given by `path` and returns an array of
* `Deno.FileInfo`.
*
- * const files = Deno.readDirSync("/");
+ * const files = Deno.readdirSync("/");
*
* Requires `allow-read` permission. */
-export function readDirSync(path: string): FileInfo[] {
+export function readdirSync(path: string): FileInfo[] {
return res(sendSync("op_read_dir", { path }));
}
@@ -29,9 +29,9 @@ export function readDirSync(path: string): FileInfo[] {
*
* Reads the directory given by `path` and resolves to an array of `Deno.FileInfo`.
*
- * const files = await Deno.readDir("/");
+ * const files = await Deno.readdir("/");
*
* Requires `allow-read` permission. */
-export async function readDir(path: string): Promise<FileInfo[]> {
+export async function readdir(path: string): Promise<FileInfo[]> {
return res(await sendAsync("op_read_dir", { path }));
}
diff --git a/cli/js/read_dir_test.ts b/cli/js/read_dir_test.ts
index 6df4373cf..95936c645 100644
--- a/cli/js/read_dir_test.ts
+++ b/cli/js/read_dir_test.ts
@@ -21,15 +21,15 @@ function assertSameContent(files: FileInfo[]): void {
assertEquals(counter, 2);
}
-unitTest({ perms: { read: true } }, function readDirSyncSuccess(): void {
- const files = Deno.readDirSync("cli/tests/");
+unitTest({ perms: { read: true } }, function readdirSyncSuccess(): void {
+ const files = Deno.readdirSync("cli/tests/");
assertSameContent(files);
});
-unitTest({ perms: { read: false } }, function readDirSyncPerm(): void {
+unitTest({ perms: { read: false } }, function readdirSyncPerm(): void {
let caughtError = false;
try {
- Deno.readDirSync("tests/");
+ Deno.readdirSync("tests/");
} catch (e) {
caughtError = true;
assert(e instanceof Deno.errors.PermissionDenied);
@@ -37,12 +37,12 @@ unitTest({ perms: { read: false } }, function readDirSyncPerm(): void {
assert(caughtError);
});
-unitTest({ perms: { read: true } }, function readDirSyncNotDir(): void {
+unitTest({ perms: { read: true } }, function readdirSyncNotDir(): void {
let caughtError = false;
let src;
try {
- src = Deno.readDirSync("cli/tests/fixture.json");
+ src = Deno.readdirSync("cli/tests/fixture.json");
} catch (err) {
caughtError = true;
assert(err instanceof Error);
@@ -51,12 +51,12 @@ unitTest({ perms: { read: true } }, function readDirSyncNotDir(): void {
assertEquals(src, undefined);
});
-unitTest({ perms: { read: true } }, function readDirSyncNotFound(): void {
+unitTest({ perms: { read: true } }, function readdirSyncNotFound(): void {
let caughtError = false;
let src;
try {
- src = Deno.readDirSync("bad_dir_name");
+ src = Deno.readdirSync("bad_dir_name");
} catch (err) {
caughtError = true;
assert(err instanceof Deno.errors.NotFound);
@@ -65,19 +65,19 @@ unitTest({ perms: { read: true } }, function readDirSyncNotFound(): void {
assertEquals(src, undefined);
});
-unitTest({ perms: { read: true } }, async function readDirSuccess(): Promise<
+unitTest({ perms: { read: true } }, async function readdirSuccess(): Promise<
void
> {
- const files = await Deno.readDir("cli/tests/");
+ const files = await Deno.readdir("cli/tests/");
assertSameContent(files);
});
-unitTest({ perms: { read: false } }, async function readDirPerm(): Promise<
+unitTest({ perms: { read: false } }, async function readdirPerm(): Promise<
void
> {
let caughtError = false;
try {
- await Deno.readDir("tests/");
+ await Deno.readdir("tests/");
} catch (e) {
caughtError = true;
assert(e instanceof Deno.errors.PermissionDenied);
diff --git a/cli/js/test_util.ts b/cli/js/test_util.ts
index 39297273b..fa17a2f87 100644
--- a/cli/js/test_util.ts
+++ b/cli/js/test_util.ts
@@ -385,7 +385,7 @@ unitTest(
unitTest(
{ perms: { read: true } },
async function assertAllUnitTestFilesImported(): Promise<void> {
- const directoryTestFiles = Deno.readDirSync("./cli/js")
+ const directoryTestFiles = Deno.readdirSync("./cli/js")
.map(k => k.name)
.filter(file => file!.endsWith("_test.ts"));
const unitTestsFile: Uint8Array = Deno.readFileSync(