From f7bf4038dc7fcf3adc09697797da1c68c932eadc Mon Sep 17 00:00:00 2001
From: Jacky Zhao <j.zhao2k19@gmail.com>
Date: Thu, 06 Jul 2023 23:56:30 +0000
Subject: [PATCH] fix path parsing

---
 quartz/build.ts |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/quartz/build.ts b/quartz/build.ts
index 60a1a51..752f57a 100644
--- a/quartz/build.ts
+++ b/quartz/build.ts
@@ -14,7 +14,6 @@
   directory: string
   verbose: boolean
   output: string
-  clean: boolean
   serve: boolean
   port: number
 }
@@ -34,11 +33,9 @@
   }
 
   // clean
-  if (argv.clean) {
-    perf.addEvent('clean')
-    await rimraf(output)
-    console.log(`Cleaned output directory \`${output}\` in ${perf.timeSince('clean')}`)
-  }
+  perf.addEvent('clean')
+  await rimraf(output)
+  console.log(`Cleaned output directory \`${output}\` in ${perf.timeSince('clean')}`)
 
   // glob
   perf.addEvent('glob')
@@ -57,10 +54,18 @@
 
   if (argv.serve) {
     const server = http.createServer(async (req, res) => {
-      return serveHandler(req, res, {
+      let status = 200
+      const result = await serveHandler(req, res, {
         public: output,
         directoryListing: false,
+      }, {
+        async sendError() {
+          status = 404
+        },
       })
+      const statusString = status === 200 ? chalk.green(`[${status}]`) : chalk.red(`[${status}]`)
+      console.log(statusString + chalk.grey(` ${req.url}`))
+      return result
     })
     server.listen(argv.port)
     console.log(`Started a Quartz server listening at http://localhost:${argv.port}`)

--
Gitblit v1.10.0