From c1ccfa70cf334a6ade8388f124387514731ce17d Mon Sep 17 00:00:00 2001 From: Andy Burke Date: Sun, 22 Jun 2025 13:45:02 -0700 Subject: [PATCH] fix: try to use fs.walk to avoid issues with jsr.io --- server.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/server.ts b/server.ts index c3bfcd5..48982fa 100644 --- a/server.ts +++ b/server.ts @@ -6,6 +6,7 @@ import * as colors from '@std/fmt/colors'; import * as fs from '@std/fs'; import * as path from '@std/path'; +import { walk } from '@std/fs'; const DEFAULT_HANDLER_DIRECTORIES = [path.join(import.meta.dirname ?? '.', 'handlers')]; @@ -108,16 +109,22 @@ export class SERVER { DEFAULT_HANDLER_DIRECTORIES; for (const handler_directory of HANDLERS_DIRECTORIES) { - const resolved_handler_directory_glob = path.resolve(path.join(handler_directory, '*.ts')); - for await (const globbed_record of fs.expandGlob(resolved_handler_directory_glob)) { - if (!globbed_record.isFile) { + const root_directory = path.resolve(handler_directory); + + for await ( + const entry of walk(root_directory, { + exts: ['.ts'], + skip: [/\.test\.ts$/] + }) + ) { + if (!entry.isFile) { continue; } - const import_path = new URL('file://' + globbed_record.path, import.meta.url).toString(); + const import_path = new URL('file://' + entry.path, import.meta.url).toString(); const handler_module: HANDLER_MODULE = await import(import_path); if (typeof handler_module.default !== 'function') { - console.warn(`Could not load handler, no default exported function: ${globbed_record.path}`); + console.warn(`Could not load handler, no default exported function: ${entry.path}`); continue; }