diff options
Diffstat (limited to 'bin')
| -rw-r--r-- | bin/serve.fnl | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/bin/serve.fnl b/bin/serve.fnl index b18d842..de5b4b3 100644 --- a/bin/serve.fnl +++ b/bin/serve.fnl @@ -3,6 +3,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)))))) + (fn ends-with [str end] (= (string.sub str (- (# end))) end)) @@ -32,3 +50,6 @@ (luna.router.route "GET /" router) (luna.router.static "GET /static/" "static/") + +(when luna.debug + (luna.evalfn (fn [code] (fennel.eval code {:env _G})))) |
