fix: recurse for indexed items properly
This commit is contained in:
parent
e46f9cefb7
commit
8f70191586
3 changed files with 103 additions and 54 deletions
|
|
@ -27,12 +27,11 @@ export async function* walk<T>(
|
|||
|
||||
const entries: WALK_ENTRY<T>[] = [];
|
||||
|
||||
for await (const dir_entry of Deno.readDir(root_path)) {
|
||||
const full_path = path.join(root, dir_entry.name);
|
||||
const info = await Deno.lstat(full_path);
|
||||
const entry = {
|
||||
path: full_path,
|
||||
info,
|
||||
const root_info: Deno.FileInfo = await Deno.lstat(root_path);
|
||||
if (!root_info.isDirectory) {
|
||||
const entry: WALK_ENTRY<T> = {
|
||||
path: root_path,
|
||||
info: root_info,
|
||||
depth,
|
||||
load: function () {
|
||||
return JSON.parse(Deno.readTextFileSync(this.path)) as T;
|
||||
|
|
@ -40,6 +39,21 @@ export async function* walk<T>(
|
|||
};
|
||||
|
||||
entries.push(entry);
|
||||
} else {
|
||||
for await (const dir_entry of Deno.readDir(root_path)) {
|
||||
const full_path = path.join(root, dir_entry.name);
|
||||
const info = await Deno.lstat(full_path);
|
||||
const entry = {
|
||||
path: full_path,
|
||||
info,
|
||||
depth,
|
||||
load: function () {
|
||||
return JSON.parse(Deno.readTextFileSync(this.path)) as T;
|
||||
}
|
||||
};
|
||||
|
||||
entries.push(entry);
|
||||
}
|
||||
}
|
||||
|
||||
if (sort) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue