diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2018-11-04 10:15:04 +0000 |
|---|---|---|
| committer | s-ol <s-ol@users.noreply.github.com> | 2018-11-04 10:29:44 +0000 |
| commit | 7ce3675b20a6b8844d73cd185011d8bc11c2b942 (patch) | |
| tree | ffe04f0299926492f1418295de992fadc0fac152 /bundle.moon | |
| parent | small fixes (diff) | |
| download | mmm-7ce3675b20a6b8844d73cd185011d8bc11c2b942.tar.gz mmm-7ce3675b20a6b8844d73cd185011d8bc11c2b942.zip | |
preload bundles
Diffstat (limited to 'bundle.moon')
| -rw-r--r-- | bundle.moon | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/bundle.moon b/bundle.moon new file mode 100644 index 0000000..5d855ea --- /dev/null +++ b/bundle.moon @@ -0,0 +1,24 @@ +output_name = assert arg[1], "please specify the output directory" + +escape = (str) -> string.format '%q', str + +with io.open output_name, 'w' + \write "local p = package.preload\n" + + for i=2, #arg + file_name = arg[i] + + file = io.open file_name, 'r' + code = file\read '*all' + file\close! + + module = file_name\gsub '/', '.' + module = module\gsub '%.lua$', '' + module = module\gsub '%.init$', '' + module = module\match '^dist%.(.*)' + + file_name = escape file_name + code = escape code + module = escape module + + \write "if not p[#{module}] then p[#{module}] = load(#{code}, #{file_name}) end\n" |
