hack workaround that might not even work, thanks jsr for being unusable
This commit is contained in:
parent
5de39d8573
commit
3b1a969145
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@bearmetal/router",
|
"name": "@bearmetal/router",
|
||||||
"description": "A simple router for Deno",
|
"description": "A simple router for Deno",
|
||||||
"version": "0.2.3-a",
|
"version": "0.2.3-b",
|
||||||
"stable": true,
|
"stable": true,
|
||||||
"files": [
|
"files": [
|
||||||
"mod.ts",
|
"mod.ts",
|
||||||
|
@ -25,7 +25,7 @@ function crawl(dir: string, callback: (path: string) => void) {
|
|||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
export class FileRouter extends Router {
|
export class FileRouter extends Router {
|
||||||
constructor(root: string) {
|
constructor(root: string, _import?: (path: string) => Promise<unknown>) {
|
||||||
super();
|
super();
|
||||||
crawl(root, async (path) => {
|
crawl(root, async (path) => {
|
||||||
let relativePath = path.replace(root, "").replace(/index\/?/, "");
|
let relativePath = path.replace(root, "").replace(/index\/?/, "");
|
||||||
@ -36,7 +36,9 @@ export class FileRouter extends Router {
|
|||||||
: `${Deno.cwd()}/${path.replace(/^.?.?\//, "")}`;
|
: `${Deno.cwd()}/${path.replace(/^.?.?\//, "")}`;
|
||||||
}
|
}
|
||||||
relativePath = relativePath.replace(/\.[tj]s/, "");
|
relativePath = relativePath.replace(/\.[tj]s/, "");
|
||||||
const handlers = await import("file://" + path);
|
const handlers = _import
|
||||||
|
? await _import(path)
|
||||||
|
: await import("file://" + path);
|
||||||
|
|
||||||
if (handlers.default) {
|
if (handlers.default) {
|
||||||
handlers.default instanceof Router
|
handlers.default instanceof Router
|
||||||
|
Loading…
x
Reference in New Issue
Block a user