diff options
-rw-r--r-- | cli/js/deno.ts | 6 | ||||
-rw-r--r-- | cli/js/lib.deno.ns.d.ts | 28 | ||||
-rw-r--r-- | cli/js/ops/fs/read_dir.ts | 4 | ||||
-rw-r--r-- | cli/js/ops/fs/read_link.ts | 4 | ||||
-rw-r--r-- | cli/js/ops/fs/real_path.ts (renamed from cli/js/ops/fs/realpath.ts) | 4 | ||||
-rw-r--r-- | cli/js/tests/read_dir_test.ts | 24 | ||||
-rw-r--r-- | cli/js/tests/read_link_test.ts | 20 | ||||
-rw-r--r-- | cli/js/tests/real_path_test.ts (renamed from cli/js/tests/realpath_test.ts) | 32 | ||||
-rw-r--r-- | cli/js/tests/test_util.ts | 2 | ||||
-rw-r--r-- | cli/js/tests/unit_tests.ts | 2 | ||||
-rw-r--r-- | std/fs/copy.ts | 8 | ||||
-rw-r--r-- | std/fs/empty_dir.ts | 6 | ||||
-rw-r--r-- | std/fs/walk.ts | 6 | ||||
-rwxr-xr-x | std/http/file_server.ts | 6 | ||||
-rw-r--r-- | std/node/_fs/_fs_dir.ts | 4 | ||||
-rw-r--r-- | std/node/_fs/_fs_readlink.ts | 2 | ||||
-rw-r--r-- | std/node/module.ts | 2 |
17 files changed, 80 insertions, 80 deletions
diff --git a/cli/js/deno.ts b/cli/js/deno.ts index d7a40648a..95db91f96 100644 --- a/cli/js/deno.ts +++ b/cli/js/deno.ts @@ -90,11 +90,11 @@ export { export { openPlugin } from "./ops/plugins.ts"; export { kill } from "./ops/process.ts"; export { run, RunOptions, Process, ProcessStatus } from "./process.ts"; -export { DirEntry, readdirSync, readdir } from "./ops/fs/read_dir.ts"; +export { DirEntry, readDirSync, readDir } from "./ops/fs/read_dir.ts"; export { readFileSync, readFile } from "./read_file.ts"; export { readTextFileSync, readTextFile } from "./read_text_file.ts"; -export { readlinkSync, readlink } from "./ops/fs/read_link.ts"; -export { realpathSync, realpath } from "./ops/fs/realpath.ts"; +export { readLinkSync, readLink } from "./ops/fs/read_link.ts"; +export { realPathSync, realPath } from "./ops/fs/real_path.ts"; export { removeSync, remove, RemoveOptions } from "./ops/fs/remove.ts"; export { renameSync, rename } from "./ops/fs/rename.ts"; export { resources, close } from "./ops/resources.ts"; diff --git a/cli/js/lib.deno.ns.d.ts b/cli/js/lib.deno.ns.d.ts index aca0fc114..c1a175da4 100644 --- a/cli/js/lib.deno.ns.d.ts +++ b/cli/js/lib.deno.ns.d.ts @@ -1366,25 +1366,25 @@ declare namespace Deno { * * // e.g. given /home/alice/file.txt and current directory /home/alice * Deno.symlinkSync("file.txt", "symlink_file.txt"); - * const realPath = Deno.realpathSync("./file.txt"); - * const realSymLinkPath = Deno.realpathSync("./symlink_file.txt"); + * const realPath = Deno.realPathSync("./file.txt"); + * const realSymLinkPath = Deno.realPathSync("./symlink_file.txt"); * console.log(realPath); // outputs "/home/alice/file.txt" * console.log(realSymLinkPath); // outputs "/home/alice/file.txt" * * Requires `allow-read` permission. */ - export function realpathSync(path: string): string; + export function realPathSync(path: string): string; /** Resolves to the absolute normalized path, with symbolic links resolved. * * // e.g. given /home/alice/file.txt and current directory /home/alice * await Deno.symlink("file.txt", "symlink_file.txt"); - * const realPath = await Deno.realpath("./file.txt"); - * const realSymLinkPath = await Deno.realpath("./symlink_file.txt"); + * const realPath = await Deno.realPath("./file.txt"); + * const realSymLinkPath = await Deno.realPath("./symlink_file.txt"); * console.log(realPath); // outputs "/home/alice/file.txt" * console.log(realSymLinkPath); // outputs "/home/alice/file.txt" * * Requires `allow-read` permission. */ - export function realpath(path: string): Promise<string>; + export function realPath(path: string): Promise<string>; export interface DirEntry { name: string; @@ -1396,26 +1396,26 @@ declare namespace Deno { /** Synchronously reads the directory given by `path` and returns an iterable * of `Deno.DirEntry`. * - * for (const dirEntry of Deno.readdirSync("/")) { + * for (const dirEntry of Deno.readDirSync("/")) { * console.log(dirEntry.name); * } * * Throws error if `path` is not a directory. * * Requires `allow-read` permission. */ - export function readdirSync(path: string): Iterable<DirEntry>; + export function readDirSync(path: string): Iterable<DirEntry>; /** Reads the directory given by `path` and returns an async iterable of * `Deno.DirEntry`. * - * for await (const dirEntry of Deno.readdir("/")) { + * for await (const dirEntry of Deno.readDir("/")) { * console.log(dirEntry.name); * } * * Throws error if `path` is not a directory. * * Requires `allow-read` permission. */ - export function readdir(path: string): AsyncIterable<DirEntry>; + export function readDir(path: string): AsyncIterable<DirEntry>; /** Synchronously copies the contents and permissions of one file to another * specified path, by default creating a new file if needed, else overwriting. @@ -1440,22 +1440,22 @@ declare namespace Deno { /** Returns the full path destination of the named symbolic link. * * Deno.symlinkSync("./test.txt", "./test_link.txt"); - * const target = Deno.readlinkSync("./test_link.txt"); // full path of ./test.txt + * const target = Deno.readLinkSync("./test_link.txt"); // full path of ./test.txt * * Throws TypeError if called with a hard link * * Requires `allow-read` permission. */ - export function readlinkSync(path: string): string; + export function readLinkSync(path: string): string; /** Resolves to the full path destination of the named symbolic link. * * await Deno.symlink("./test.txt", "./test_link.txt"); - * const target = await Deno.readlink("./test_link.txt"); // full path of ./test.txt + * const target = await Deno.readLink("./test_link.txt"); // full path of ./test.txt * * Throws TypeError if called with a hard link * * Requires `allow-read` permission. */ - export function readlink(path: string): Promise<string>; + export function readLink(path: string): Promise<string>; /** Resolves to a `Deno.FileInfo` for the specified `path`. If `path` is a * symlink, information for the symlink will be returned instead of what it diff --git a/cli/js/ops/fs/read_dir.ts b/cli/js/ops/fs/read_dir.ts index 7d65fed48..1e8d79edc 100644 --- a/cli/js/ops/fs/read_dir.ts +++ b/cli/js/ops/fs/read_dir.ts @@ -16,11 +16,11 @@ function res(response: ReadDirResponse): DirEntry[] { return response.entries; } -export function readdirSync(path: string): Iterable<DirEntry> { +export function readDirSync(path: string): Iterable<DirEntry> { return res(sendSync("op_read_dir", { path }))[Symbol.iterator](); } -export function readdir(path: string): AsyncIterable<DirEntry> { +export function readDir(path: string): AsyncIterable<DirEntry> { const array = sendAsync("op_read_dir", { path }).then(res); return { async *[Symbol.asyncIterator](): AsyncIterableIterator<DirEntry> { diff --git a/cli/js/ops/fs/read_link.ts b/cli/js/ops/fs/read_link.ts index 4ac8db3db..bcd27ccb7 100644 --- a/cli/js/ops/fs/read_link.ts +++ b/cli/js/ops/fs/read_link.ts @@ -1,10 +1,10 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. import { sendSync, sendAsync } from "../dispatch_json.ts"; -export function readlinkSync(path: string): string { +export function readLinkSync(path: string): string { return sendSync("op_read_link", { path }); } -export function readlink(path: string): Promise<string> { +export function readLink(path: string): Promise<string> { return sendAsync("op_read_link", { path }); } diff --git a/cli/js/ops/fs/realpath.ts b/cli/js/ops/fs/real_path.ts index e8a904079..ab95b9583 100644 --- a/cli/js/ops/fs/realpath.ts +++ b/cli/js/ops/fs/real_path.ts @@ -1,10 +1,10 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. import { sendSync, sendAsync } from "../dispatch_json.ts"; -export function realpathSync(path: string): string { +export function realPathSync(path: string): string { return sendSync("op_realpath", { path }); } -export function realpath(path: string): Promise<string> { +export function realPath(path: string): Promise<string> { return sendAsync("op_realpath", { path }); } diff --git a/cli/js/tests/read_dir_test.ts b/cli/js/tests/read_dir_test.ts index f1c7ea121..79e2a1507 100644 --- a/cli/js/tests/read_dir_test.ts +++ b/cli/js/tests/read_dir_test.ts @@ -14,15 +14,15 @@ function assertSameContent(files: Deno.DirEntry[]): void { assertEquals(counter, 1); } -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); @@ -30,12 +30,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); @@ -44,12 +44,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); @@ -58,22 +58,22 @@ 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 = []; - for await (const dirEntry of Deno.readdir("cli/tests/")) { + for await (const dirEntry of Deno.readDir("cli/tests/")) { files.push(dirEntry); } 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/")[Symbol.asyncIterator]().next(); + await Deno.readDir("tests/")[Symbol.asyncIterator]().next(); } catch (e) { caughtError = true; assert(e instanceof Deno.errors.PermissionDenied); diff --git a/cli/js/tests/read_link_test.ts b/cli/js/tests/read_link_test.ts index 6e8c29a61..6821d8dc8 100644 --- a/cli/js/tests/read_link_test.ts +++ b/cli/js/tests/read_link_test.ts @@ -3,7 +3,7 @@ import { unitTest, assert, assertEquals } from "./test_util.ts"; unitTest( { perms: { write: true, read: true } }, - function readlinkSyncSuccess(): void { + function readLinkSyncSuccess(): void { const testDir = Deno.makeTempDirSync(); const target = testDir + "/target"; const symlink = testDir + "/symln"; @@ -12,16 +12,16 @@ unitTest( // See https://github.com/denoland/deno/issues/815. if (Deno.build.os !== "windows") { Deno.symlinkSync(target, symlink); - const targetPath = Deno.readlinkSync(symlink); + const targetPath = Deno.readLinkSync(symlink); assertEquals(targetPath, target); } } ); -unitTest({ perms: { read: false } }, function readlinkSyncPerm(): void { +unitTest({ perms: { read: false } }, function readLinkSyncPerm(): void { let caughtError = false; try { - Deno.readlinkSync("/symlink"); + Deno.readLinkSync("/symlink"); } catch (e) { caughtError = true; assert(e instanceof Deno.errors.PermissionDenied); @@ -29,11 +29,11 @@ unitTest({ perms: { read: false } }, function readlinkSyncPerm(): void { assert(caughtError); }); -unitTest({ perms: { read: true } }, function readlinkSyncNotFound(): void { +unitTest({ perms: { read: true } }, function readLinkSyncNotFound(): void { let caughtError = false; let data; try { - data = Deno.readlinkSync("bad_filename"); + data = Deno.readLinkSync("bad_filename"); } catch (e) { caughtError = true; assert(e instanceof Deno.errors.NotFound); @@ -44,7 +44,7 @@ unitTest({ perms: { read: true } }, function readlinkSyncNotFound(): void { unitTest( { perms: { write: true, read: true } }, - async function readlinkSuccess(): Promise<void> { + async function readLinkSuccess(): Promise<void> { const testDir = Deno.makeTempDirSync(); const target = testDir + "/target"; const symlink = testDir + "/symln"; @@ -53,18 +53,18 @@ unitTest( // See https://github.com/denoland/deno/issues/815. if (Deno.build.os !== "windows") { Deno.symlinkSync(target, symlink); - const targetPath = await Deno.readlink(symlink); + const targetPath = await Deno.readLink(symlink); assertEquals(targetPath, target); } } ); -unitTest({ perms: { read: false } }, async function readlinkPerm(): Promise< +unitTest({ perms: { read: false } }, async function readLinkPerm(): Promise< void > { let caughtError = false; try { - await Deno.readlink("/symlink"); + await Deno.readLink("/symlink"); } catch (e) { caughtError = true; assert(e instanceof Deno.errors.PermissionDenied); diff --git a/cli/js/tests/realpath_test.ts b/cli/js/tests/real_path_test.ts index d76094366..c88955270 100644 --- a/cli/js/tests/realpath_test.ts +++ b/cli/js/tests/real_path_test.ts @@ -1,9 +1,9 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. import { unitTest, assert } from "./test_util.ts"; -unitTest({ perms: { read: true } }, function realpathSyncSuccess(): void { +unitTest({ perms: { read: true } }, function realPathSyncSuccess(): void { const incompletePath = "cli/tests/fixture.json"; - const realPath = Deno.realpathSync(incompletePath); + const realPath = Deno.realPathSync(incompletePath); if (Deno.build.os !== "windows") { assert(realPath.startsWith("/")); } else { @@ -17,22 +17,22 @@ unitTest( ignore: Deno.build.os === "windows", perms: { read: true, write: true }, }, - function realpathSyncSymlink(): void { + function realPathSyncSymlink(): void { const testDir = Deno.makeTempDirSync(); const target = testDir + "/target"; const symlink = testDir + "/symln"; Deno.mkdirSync(target); Deno.symlinkSync(target, symlink); - const targetPath = Deno.realpathSync(symlink); + const targetPath = Deno.realPathSync(symlink); assert(targetPath.startsWith("/")); assert(targetPath.endsWith("/target")); } ); -unitTest({ perms: { read: false } }, function realpathSyncPerm(): void { +unitTest({ perms: { read: false } }, function realPathSyncPerm(): void { let caughtError = false; try { - Deno.realpathSync("some_file"); + Deno.realPathSync("some_file"); } catch (e) { caughtError = true; assert(e instanceof Deno.errors.PermissionDenied); @@ -40,10 +40,10 @@ unitTest({ perms: { read: false } }, function realpathSyncPerm(): void { assert(caughtError); }); -unitTest({ perms: { read: true } }, function realpathSyncNotFound(): void { +unitTest({ perms: { read: true } }, function realPathSyncNotFound(): void { let caughtError = false; try { - Deno.realpathSync("bad_filename"); + Deno.realPathSync("bad_filename"); } catch (e) { caughtError = true; assert(e instanceof Deno.errors.NotFound); @@ -51,11 +51,11 @@ unitTest({ perms: { read: true } }, function realpathSyncNotFound(): void { assert(caughtError); }); -unitTest({ perms: { read: true } }, async function realpathSuccess(): Promise< +unitTest({ perms: { read: true } }, async function realPathSuccess(): Promise< void > { const incompletePath = "cli/tests/fixture.json"; - const realPath = await Deno.realpath(incompletePath); + const realPath = await Deno.realPath(incompletePath); if (Deno.build.os !== "windows") { assert(realPath.startsWith("/")); } else { @@ -69,24 +69,24 @@ unitTest( ignore: Deno.build.os === "windows", perms: { read: true, write: true }, }, - async function realpathSymlink(): Promise<void> { + async function realPathSymlink(): Promise<void> { const testDir = Deno.makeTempDirSync(); const target = testDir + "/target"; const symlink = testDir + "/symln"; Deno.mkdirSync(target); Deno.symlinkSync(target, symlink); - const targetPath = await Deno.realpath(symlink); + const targetPath = await Deno.realPath(symlink); assert(targetPath.startsWith("/")); assert(targetPath.endsWith("/target")); } ); -unitTest({ perms: { read: false } }, async function realpathPerm(): Promise< +unitTest({ perms: { read: false } }, async function realPathPerm(): Promise< void > { let caughtError = false; try { - await Deno.realpath("some_file"); + await Deno.realPath("some_file"); } catch (e) { caughtError = true; assert(e instanceof Deno.errors.PermissionDenied); @@ -94,12 +94,12 @@ unitTest({ perms: { read: false } }, async function realpathPerm(): Promise< assert(caughtError); }); -unitTest({ perms: { read: true } }, async function realpathNotFound(): Promise< +unitTest({ perms: { read: true } }, async function realPathNotFound(): Promise< void > { let caughtError = false; try { - await Deno.realpath("bad_filename"); + await Deno.realPath("bad_filename"); } catch (e) { caughtError = true; assert(e instanceof Deno.errors.NotFound); diff --git a/cli/js/tests/test_util.ts b/cli/js/tests/test_util.ts index 516834454..24186db71 100644 --- a/cli/js/tests/test_util.ts +++ b/cli/js/tests/test_util.ts @@ -332,7 +332,7 @@ unitTest(function permissionsMatches(): void { unitTest( { perms: { read: true } }, function assertAllUnitTestFilesImported(): void { - const directoryTestFiles = [...Deno.readdirSync("./cli/js/tests/")] + const directoryTestFiles = [...Deno.readDirSync("./cli/js/tests/")] .map((k) => k.name) .filter( (file) => diff --git a/cli/js/tests/unit_tests.ts b/cli/js/tests/unit_tests.ts index dd4abf116..fa168e6dd 100644 --- a/cli/js/tests/unit_tests.ts +++ b/cli/js/tests/unit_tests.ts @@ -42,7 +42,7 @@ import "./net_test.ts"; import "./os_test.ts"; import "./permissions_test.ts"; import "./process_test.ts"; -import "./realpath_test.ts"; +import "./real_path_test.ts"; import "./read_dir_test.ts"; import "./read_text_file_test.ts"; import "./read_file_test.ts"; diff --git a/std/fs/copy.ts b/std/fs/copy.ts index d442e46ae..609a8437b 100644 --- a/std/fs/copy.ts +++ b/std/fs/copy.ts @@ -109,7 +109,7 @@ async function copySymLink( options: CopyOptions ): Promise<void> { await ensureValidCopy(src, dest, options); - const originSrcFilePath = await Deno.readlink(src); + const originSrcFilePath = await Deno.readLink(src); const type = getFileInfoType(await Deno.lstat(src)); await Deno.symlink(originSrcFilePath, dest, type); if (options.preserveTimestamps) { @@ -127,7 +127,7 @@ function copySymlinkSync( options: CopyOptions ): void { ensureValidCopySync(src, dest, options); - const originSrcFilePath = Deno.readlinkSync(src); + const originSrcFilePath = Deno.readLinkSync(src); const type = getFileInfoType(Deno.lstatSync(src)); Deno.symlinkSync(originSrcFilePath, dest, type); if (options.preserveTimestamps) { @@ -157,7 +157,7 @@ async function copyDir( await Deno.utime(dest, srcStatInfo.atime, srcStatInfo.mtime); } - for await (const entry of Deno.readdir(src)) { + for await (const entry of Deno.readDir(src)) { const srcPath = path.join(src, entry.name); const destPath = path.join(dest, path.basename(srcPath as string)); if (entry.isSymlink) { @@ -185,7 +185,7 @@ function copyDirSync(src: string, dest: string, options: CopyOptions): void { Deno.utimeSync(dest, srcStatInfo.atime, srcStatInfo.mtime); } - for (const entry of Deno.readdirSync(src)) { + for (const entry of Deno.readDirSync(src)) { assert(entry.name != null, "file.name must be set"); const srcPath = path.join(src, entry.name); const destPath = path.join(dest, path.basename(srcPath as string)); diff --git a/std/fs/empty_dir.ts b/std/fs/empty_dir.ts index 5e860c65f..8c3083cee 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. @@ -11,7 +11,7 @@ const { readdir, readdirSync, mkdir, mkdirSync, remove, removeSync } = Deno; export async function emptyDir(dir: string): Promise<void> { try { const items = []; - for await (const dirEntry of readdir(dir)) { + for await (const dirEntry of readDir(dir)) { items.push(dirEntry); } @@ -41,7 +41,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 a99d35a50..d01f35167 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 { basename, join, normalize } from "../path/mod.ts"; -const { readdir, readdirSync, stat, statSync } = Deno; +const { readDir, readDirSync, stat, statSync } = Deno; export function createWalkEntrySync(path: string): WalkEntry { path = normalize(path); @@ -103,7 +103,7 @@ export async function* walk( if (maxDepth < 1 || !include(root, undefined, undefined, skip)) { return; } - for await (const entry of readdir(root)) { + for await (const entry of readDir(root)) { if (entry.isSymlink) { if (followSymlinks) { // TODO(ry) Re-enable followSymlinks. @@ -156,7 +156,7 @@ export function* walkSync( if (maxDepth < 1 || !include(root, undefined, undefined, skip)) { return; } - for (const entry of readdirSync(root)) { + for (const entry of readDirSync(root)) { if (entry.isSymlink) { if (followSymlinks) { unimplemented(); diff --git a/std/http/file_server.ts b/std/http/file_server.ts index c225dbef1..d847642d9 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, extname } from "../path/mod.ts"; import { listenAndServe, ServerRequest, Response } from "./server.ts"; import { parse } from "../flags/mod.ts"; @@ -133,14 +133,14 @@ export async function serveFile( }; } -// 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[] = []; - for await (const entry of readdir(dirPath)) { + for await (const entry of readDir(dirPath)) { const filePath = posix.join(dirPath, entry.name); const fileUrl = posix.join(dirUrl, entry.name); if (entry.name === "index.html" && entry.isFile) { diff --git a/std/node/_fs/_fs_dir.ts b/std/node/_fs/_fs_dir.ts index 543cf14ee..a39422ce0 100644 --- a/std/node/_fs/_fs_dir.ts +++ b/std/node/_fs/_fs_dir.ts @@ -20,7 +20,7 @@ export default class Dir { read(callback?: Function): Promise<Dirent | null> { return new Promise((resolve, reject) => { if (!this.asyncIterator) { - this.asyncIterator = Deno.readdir(this.path)[Symbol.asyncIterator](); + this.asyncIterator = Deno.readDir(this.path)[Symbol.asyncIterator](); } assert(this.asyncIterator); this.asyncIterator @@ -42,7 +42,7 @@ export default class Dir { readSync(): Dirent | null { if (!this.syncIterator) { - this.syncIterator = Deno.readdirSync(this.path)![Symbol.iterator](); + this.syncIterator = Deno.readDirSync(this.path)![Symbol.iterator](); } const file: Deno.DirEntry = this.syncIterator.next().value; diff --git a/std/node/_fs/_fs_readlink.ts b/std/node/_fs/_fs_readlink.ts index 1fd7e3c14..b32cd9dd3 100644 --- a/std/node/_fs/_fs_readlink.ts +++ b/std/node/_fs/_fs_readlink.ts @@ -5,7 +5,7 @@ import { notImplemented, } from "../_utils.ts"; -const { readlink: denoReadlink, readlinkSync: denoReadlinkSync } = Deno; +const { readLink: denoReadlink, readLinkSync: denoReadlinkSync } = Deno; type ReadlinkCallback = ( err: MaybeEmpty<Error>, diff --git a/std/node/module.ts b/std/node/module.ts index 9203764f0..8969e80d9 100644 --- a/std/node/module.ts +++ b/std/node/module.ts @@ -758,7 +758,7 @@ function toRealPath(requestPath: string): string { let fullPath = requestPath; while (true) { try { - fullPath = Deno.readlinkSync(fullPath); + fullPath = Deno.readLinkSync(fullPath); } catch { break; } |