diff options
Diffstat (limited to 'nuldoc-src/commands/serve.ts')
| -rw-r--r-- | nuldoc-src/commands/serve.ts | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/nuldoc-src/commands/serve.ts b/nuldoc-src/commands/serve.ts new file mode 100644 index 0000000..b66ad2d --- /dev/null +++ b/nuldoc-src/commands/serve.ts @@ -0,0 +1,22 @@ +import { join } from "std/path/mod.ts"; +import { serveDir } from "std/http/file_server.ts"; +import { serve } from "std/http/server.ts"; +import { Config } from "../config.ts"; + +export function runServeCommand(config: Config) { + const rootDir = join(Deno.cwd(), config.locations.destDir); + serve(async (req) => { + const pathname = new URL(req.url).pathname; + if (!pathname.endsWith("css") && !pathname.endsWith("svg")) { + const p = Deno.run({ + cmd: ["./nuldoc", "build"], + }); + await p.status(); + console.log("rebuild"); + } + return serveDir(req, { + fsRoot: rootDir, + showIndex: true, + }); + }); +} |
