fix: handle queries for non-existent items
This commit is contained in:
parent
57bc0f18a0
commit
b3248ae431
3 changed files with 12 additions and 1 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import * as fs from '@std/fs';
|
||||
import * as path from '@std/path';
|
||||
|
||||
export type WALK_OPTIONS<T> = {
|
||||
|
|
@ -27,6 +28,11 @@ export async function* walk<T>(
|
|||
|
||||
const entries: WALK_ENTRY<T>[] = [];
|
||||
|
||||
const exists: boolean = await fs.exists(root_path);
|
||||
if (!exists) {
|
||||
return entries;
|
||||
}
|
||||
|
||||
const root_info: Deno.FileInfo = await Deno.lstat(root_path);
|
||||
if (!root_info.isDirectory) {
|
||||
const entry: WALK_ENTRY<T> = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue