diff options
Diffstat (limited to 'cli/js')
-rw-r--r-- | cli/js/lib.deno.ns.d.ts | 5 | ||||
-rw-r--r-- | cli/js/ops/fs/read_dir.ts | 14 | ||||
-rw-r--r-- | cli/js/ops/fs/stat.ts | 2 | ||||
-rw-r--r-- | cli/js/tests/read_dir_test.ts | 13 |
4 files changed, 14 insertions, 20 deletions
diff --git a/cli/js/lib.deno.ns.d.ts b/cli/js/lib.deno.ns.d.ts index e58ec0b55..d7d885b5b 100644 --- a/cli/js/lib.deno.ns.d.ts +++ b/cli/js/lib.deno.ns.d.ts @@ -1386,8 +1386,11 @@ declare namespace Deno { * Requires `allow-read` permission. */ export function realpath(path: string): Promise<string>; - export interface DirEntry extends FileInfo { + export interface DirEntry { name: string; + isFile: boolean; + isDirectory: boolean; + isSymlink: boolean; } /** Synchronously reads the directory given by `path` and returns an iterable diff --git a/cli/js/ops/fs/read_dir.ts b/cli/js/ops/fs/read_dir.ts index 29b8676ef..7d65fed48 100644 --- a/cli/js/ops/fs/read_dir.ts +++ b/cli/js/ops/fs/read_dir.ts @@ -1,21 +1,19 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. import { sendSync, sendAsync } from "../dispatch_json.ts"; -import { FileInfo, StatResponse, parseFileInfo } from "./stat.ts"; -export interface DirEntry extends FileInfo { +export interface DirEntry { name: string; + isFile: boolean; + isDirectory: boolean; + isSymlink: boolean; } interface ReadDirResponse { - entries: StatResponse[]; + entries: DirEntry[]; } function res(response: ReadDirResponse): DirEntry[] { - return response.entries.map( - (statRes: StatResponse): DirEntry => { - return { ...parseFileInfo(statRes), name: statRes.name! }; - } - ); + return response.entries; } export function readdirSync(path: string): Iterable<DirEntry> { diff --git a/cli/js/ops/fs/stat.ts b/cli/js/ops/fs/stat.ts index c3563a8c4..e8fd28218 100644 --- a/cli/js/ops/fs/stat.ts +++ b/cli/js/ops/fs/stat.ts @@ -29,8 +29,6 @@ export interface StatResponse { mtime: number | null; atime: number | null; birthtime: number | null; - // Null for stat(), but exists for readdir(). - name: string | null; // Unix only members dev: number; ino: number; diff --git a/cli/js/tests/read_dir_test.ts b/cli/js/tests/read_dir_test.ts index 2c7f42103..f1c7ea121 100644 --- a/cli/js/tests/read_dir_test.ts +++ b/cli/js/tests/read_dir_test.ts @@ -4,19 +4,14 @@ import { unitTest, assert, assertEquals } from "./test_util.ts"; function assertSameContent(files: Deno.DirEntry[]): void { let counter = 0; - for (const file of files) { - if (file.name === "subdir") { - assert(file.isDirectory); - counter++; - } - - if (file.name === "002_hello.ts") { - assertEquals(file.mode!, Deno.statSync(`cli/tests/${file.name}`).mode!); + for (const entry of files) { + if (entry.name === "subdir") { + assert(entry.isDirectory); counter++; } } - assertEquals(counter, 2); + assertEquals(counter, 1); } unitTest({ perms: { read: true } }, function readdirSyncSuccess(): void { |