Skip to content

Commit

Permalink
fix(internal): readDir check path isDirectory before Deno.readDir(pat…
Browse files Browse the repository at this point in the history
…h) (c4spar#781)
  • Loading branch information
mch committed Jan 8, 2025
1 parent 1d5feed commit e7a2c22
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/runtime/read_dir.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// deno-lint-ignore-file no-explicit-any
import { isDirectory } from "./is_directory.ts";

/**
* Get directory list.
Expand All @@ -12,6 +13,9 @@ export async function readDir(path: string): Promise<Array<{ name: string }>> {
path ||= ".";

if (Deno) {
if (!(await isDirectory(path))) {
return [];
}
const array = [];
for await (const item of Deno.readDir(path)) {
array.push(item);
Expand Down

0 comments on commit e7a2c22

Please sign in to comment.