diff options
Diffstat (limited to 'bin/serve.fnl')
| -rw-r--r-- | bin/serve.fnl | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/bin/serve.fnl b/bin/serve.fnl index c7bc334..8cdd673 100644 --- a/bin/serve.fnl +++ b/bin/serve.fnl @@ -17,6 +17,24 @@ (when _G.unpack (tset table :unpack _G.unpack)) +(set _G.reload + (fn [module] + (local old (require module)) + (tset package :loaded module nil) + (local (ok? new) (pcall require module)) + (if (not ok?) + (do + (tset package :loaded module old) + (error new)) + (when (= (type new) :table) + (do + (each [k v (pairs new)] + (tset old k v)) + (each [k (pairs old)] + (when (not (. new k)) + (tset old k nil))) + (tset package :loaded module old)))))) + (local db (must (luna.db.open "file:var/db.sqlite?_journal=WAL&_sync=NORMAL"))) (local query-synonyms { @@ -582,3 +600,5 @@ (must (luna.router.route "GET /" root-handler)) (must (luna.router.route "GET /robots.txt" robots-handler)) (must (luna.router.static "GET /static/" "static/")) + +(must (luna.repl (fn [code] (fennel.eval code {:env _G})))) |
