From 8844d29223626240ff99a0cdaccf1ee5a36cb3f6 Mon Sep 17 00:00:00 2001 From: s-ol Date: Fri, 19 Oct 2018 01:16:10 +1100 Subject: towards self-compiling --- server.moon | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) (limited to 'server.moon') diff --git a/server.moon b/server.moon index fb33806..d2bb683 100644 --- a/server.moon +++ b/server.moon @@ -1,33 +1,41 @@ -package.moonpath = './?.server.moon;' .. package.moonpath +package.moonpath = './?.shared.moon;./?.server.moon;' .. package.moonpath -export MODE, warn, append +export MODE, warn, relative, append, on_client MODE = 'SERVER' + +-- warning messages warn = (...) -> io.stderr\write table.concat { ... }, '\t' io.stderr\write '\n' +-- relative imports +relative = (...) -> + _require = require + path = ... + + (name) -> + name = path .. name if '.' == name\sub 1, 1 + require name + -- shorthand to append elements to body buffer = '' append = (val) -> buffer ..= val -flush = -> - with x = buffer - buffer = '' -import insert_loader from require 'duct_tape' +import compile, insert_loader from require 'duct_tape' insert_loader! -error "please specify the module to build as an argumnet" unless arg[1] - -require "app.#{arg[1]}" +on_client = (fn, ...) -> + -- warn code + append "" -print " - - - - MMM: lunar low-gravity scripting playground - - - #{flush!} - -" +{ + -- access / flush the appended data + flush: -> + with x = buffer + buffer = '' +} -- cgit v1.2.3