summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
-rw-r--r--std/fs/copy.ts4
-rw-r--r--std/fs/empty_dir.ts6
-rw-r--r--std/fs/walk.ts6
-rwxr-xr-xstd/http/file_server.ts6
-rw-r--r--std/node/_fs_dir.ts4
-rw-r--r--tools/testdata/unit_test_output1.txt4
-rw-r--r--tools/testdata/unit_test_output3.txt4
13 files changed, 46 insertions, 47 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(
diff --git a/std/fs/copy.ts b/std/fs/copy.ts
index d19c120f7..b199e9167 100644
--- a/std/fs/copy.ts
+++ b/std/fs/copy.ts
@@ -157,7 +157,7 @@ async function copyDir(
await Deno.utime(dest, srcStatInfo.accessed, srcStatInfo.modified);
}
- const files = await Deno.readDir(src);
+ const files = await Deno.readdir(src);
for (const file of files) {
assert(file.name != null, "file.name must be set");
@@ -188,7 +188,7 @@ function copyDirSync(src: string, dest: string, options: CopyOptions): void {
Deno.utimeSync(dest, srcStatInfo.accessed, srcStatInfo.modified);
}
- const files = Deno.readDirSync(src);
+ const files = Deno.readdirSync(src);
for (const file of files) {
assert(file.name != null, "file.name must be set");
diff --git a/std/fs/empty_dir.ts b/std/fs/empty_dir.ts
index a848e90a1..78b7a42f4 100644
--- a/std/fs/empty_dir.ts
+++ b/std/fs/empty_dir.ts
@@ -1,6 +1,6 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { join } from "../path/mod.ts";
-const { readDir, readDirSync, mkdir, mkdirSync, remove, removeSync } = Deno;
+const { readdir, readdirSync, mkdir, mkdirSync, remove, removeSync } = Deno;
/**
* Ensures that a directory is empty.
* Deletes directory contents if the directory is not empty.
@@ -10,7 +10,7 @@ const { readDir, readDirSync, mkdir, mkdirSync, remove, removeSync } = Deno;
*/
export async function emptyDir(dir: string): Promise<void> {
try {
- const items = await readDir(dir);
+ const items = await readdir(dir);
while (items.length) {
const item = items.shift();
@@ -38,7 +38,7 @@ export async function emptyDir(dir: string): Promise<void> {
*/
export function emptyDirSync(dir: string): void {
try {
- const items = readDirSync(dir);
+ const items = readdirSync(dir);
// if directory already exist. then remove it's child item.
while (items.length) {
diff --git a/std/fs/walk.ts b/std/fs/walk.ts
index 890114525..fbd14740b 100644
--- a/std/fs/walk.ts
+++ b/std/fs/walk.ts
@@ -3,7 +3,7 @@
// Copyright 2009 The Go Authors. All rights reserved. BSD license.
import { unimplemented, assert } from "../testing/asserts.ts";
import { join } from "../path/mod.ts";
-const { readDir, readDirSync, stat, statSync } = Deno;
+const { readdir, readdirSync, stat, statSync } = Deno;
type FileInfo = Deno.FileInfo;
export interface WalkOptions {
@@ -79,7 +79,7 @@ export async function* walk(
if (maxDepth < 1 || !include(root, undefined, undefined, skip)) {
return;
}
- const ls: FileInfo[] = await readDir(root);
+ const ls: FileInfo[] = await readdir(root);
for (const info of ls) {
if (info.isSymlink()) {
if (followSymlinks) {
@@ -133,7 +133,7 @@ export function* walkSync(
if (maxDepth < 1 || !include(root, undefined, undefined, skip)) {
return;
}
- const ls: FileInfo[] = readDirSync(root);
+ const ls: FileInfo[] = readdirSync(root);
for (const info of ls) {
if (info.isSymlink()) {
if (followSymlinks) {
diff --git a/std/http/file_server.ts b/std/http/file_server.ts
index e1fe14fcf..28eaef44d 100755
--- a/std/http/file_server.ts
+++ b/std/http/file_server.ts
@@ -6,7 +6,7 @@
// TODO Add tests like these:
// https://github.com/indexzero/http-server/blob/master/test/http-server-test.js
-const { args, stat, readDir, open, exit } = Deno;
+const { args, stat, readdir, open, exit } = Deno;
import { posix } from "../path/mod.ts";
import { listenAndServe, ServerRequest, Response } from "./server.ts";
import { parse } from "../flags/mod.ts";
@@ -113,14 +113,14 @@ async function serveFile(
return res;
}
-// TODO: simplify this after deno.stat and deno.readDir are fixed
+// TODO: simplify this after deno.stat and deno.readdir are fixed
async function serveDir(
req: ServerRequest,
dirPath: string
): Promise<Response> {
const dirUrl = `/${posix.relative(target, dirPath)}`;
const listEntry: EntryInfo[] = [];
- const fileInfos = await readDir(dirPath);
+ const fileInfos = await readdir(dirPath);
for (const fileInfo of fileInfos) {
const filePath = posix.join(dirPath, fileInfo.name ?? "");
const fileUrl = posix.join(dirUrl, fileInfo.name ?? "");
diff --git a/std/node/_fs_dir.ts b/std/node/_fs_dir.ts
index 47d0a6511..e3830bb31 100644
--- a/std/node/_fs_dir.ts
+++ b/std/node/_fs_dir.ts
@@ -29,7 +29,7 @@ export default class Dir {
return new Promise(async (resolve, reject) => {
try {
if (this.initializationOfDirectoryFilesIsRequired()) {
- const denoFiles: Deno.FileInfo[] = await Deno.readDir(this.path);
+ const denoFiles: Deno.FileInfo[] = await Deno.readdir(this.path);
this.files = denoFiles.map(file => new Dirent(file));
}
const nextFile = this.files.pop();
@@ -55,7 +55,7 @@ export default class Dir {
readSync(): Dirent | null {
if (this.initializationOfDirectoryFilesIsRequired()) {
this.files.push(
- ...Deno.readDirSync(this.path).map(file => new Dirent(file))
+ ...Deno.readdirSync(this.path).map(file => new Dirent(file))
);
}
const dirent: Dirent | undefined = this.files.pop();
diff --git a/tools/testdata/unit_test_output1.txt b/tools/testdata/unit_test_output1.txt
index 4b208319f..8a4cfdfd3 100644
--- a/tools/testdata/unit_test_output1.txt
+++ b/tools/testdata/unit_test_output1.txt
@@ -133,9 +133,9 @@ test readFileSyncNotFound_permW0N0E0
... ok
test readFileSuccess_permW0N0E0
... ok
-test readDirSyncNotDir_permW0N0E0
+test readdirSyncNotDir_permW0N0E0
... ok
-test readDirSyncNotFound_permW0N0E0
+test readdirSyncNotFound_permW0N0E0
... ok
test writeFileSyncPerm_permW0N0E0
... ok
diff --git a/tools/testdata/unit_test_output3.txt b/tools/testdata/unit_test_output3.txt
index 402261e76..f1dd7078e 100644
--- a/tools/testdata/unit_test_output3.txt
+++ b/tools/testdata/unit_test_output3.txt
@@ -163,9 +163,9 @@ test readFileSyncNotFound_permW0N0E0
... ok
test readFileSuccess_permW0N0E0
... ok
-test readDirSyncNotDir_permW0N0E0
+test readdirSyncNotDir_permW0N0E0
... ok
-test readDirSyncNotFound_permW0N0E0
+test readdirSyncNotFound_permW0N0E0
... ok
test writeFileSyncPerm_permW0N0E0
... ok