<commit_before>-- The MIT License (MIT)
-- Copyright (c) 2016 <NAME>

-- lar Generator and lua/moon builder
-- Required module:
-- lua-miniz, lua_cliargs, lpath, moonscript

larpr = require("larpr")
miniz = require("miniz")
cli   = require("cliargs")
path  = require("path")
fs    = require("path.fs")
info  = require("path.info")
moon  = require("moon")
moons = require("moonscript")
import join from path

COPYRIGHT = "Copyright (C) 1994-2017 <NAME>"
VERSION = "lar compiler 0.1.1b"

print_version = ->
    print(larpr.VERSION .. " " .. COPYRIGHT)
    print(VERSION .. " " .. COPYRIGHT)
    print("lua_cliargs: version " .. cli.VERSION)
    os.exit(0)

cli\set_name("lar.lua")
cli\argument("FOLDER", "the source files' folder")
cli\argument("OUTPUT", "path to the output lar file")
cli\flag("-b, --byte", "build source files into byte code")
cli\flag("-s, --strip", "strip when building byte code")
cli\flag("-v, --version", "prints the program's version and exits", print_version)
cli\flag("--verbose", "the script output will be very verbose")
args, err = cli\parse(arg)

if err then
    print(err)
    os.exit(0)

checkext = (src) ->
    ext = select(2, path.splitext(src))
    invild = { ".moonc", ".moon", ".lua", ".luac" }
    return moon.fold(invild, (a, b) -> a or (ext == b))

buildmoon = (src, dst) ->
    f = io.open(dst, "w")
    v, _ = moons.to_lua(io.open(src)\read("*a"))
    f\write(v)
    f\close()
buildlua =  (src, dst) ->
    fs.copy(src, dst)

dump = (src, dst, strip) ->
    f = io.open(dst, "wb")
    f\write(string.dump(loadfile(src), strip))
    f\close()

build = (src, dst) ->
    getext = (p) -> select(2, path.splitext(p))
    nt = os.tmpname()

    switch getext(src)
        when ".moon"
            buildmoon(src, nt)
        when ".lua"
            buildlua(src, nt)
        when ".luac"
            fs.copy(src, dst)<commit_msg>Fix: lar.moon with uncompatible files<commit_after>-- The MIT License (MIT)
-- Copyright (c) 2016 <NAME>

-- lar Generator and lua/moon builder
-- Required module:
-- lua-miniz, lua_cliargs, lpath, moonscript

larpr = require("larpr")
miniz = require("miniz")
cli   = require("cliargs")
path  = require("path")
fs    = require("path.fs")
info  = require("path.info")
moon  = require("moon")
moons = require("moonscript")
import join from path

COPYRIGHT = "Copyright (C) 1994-2017 <NAME>"
VERSION = "lar compiler 0.1.1b"

print_version = ->
    print(larpr.VERSION .. " " .. COPYRIGHT)
    print(VERSION .. " " .. COPYRIGHT)
    print("lua_cliargs: version " .. cli.VERSION)
    os.exit(0)

cli\set_name("lar.lua")
cli\argument("FOLDER", "the source files' folder")
cli\argument("OUTPUT", "path to the output lar file")
cli\flag("-b, --byte", "build source files into byte code")
cli\flag("-s, --strip", "strip when building byte code")
cli\flag("-v, --version", "prints the program's version and exits", print_version)
cli\flag("--verbose", "the script output will be very verbose")
args, err = cli\parse(arg)

if err then
    print(err)
    os.exit(0)

checkext = (src) ->
    ext = select(2, path.splitext(src))
    invild = { ".moonc", ".moon", ".lua", ".luac" }
    for v in *invild
        return true if ext == v
    return false

buildmoon = (src, dst) ->
    f = io.open(dst, "w")
    v, _ = moons.to_lua(io.open(src)\read("*a"))
    f\write(v)
    f\close()
buildlua =  (src, dst) ->
    fs.copy(src, dst)

dump = (src, dst, strip) ->
    f = io.open(dst, "wb")
    f\write(string.dump(loadfile(src), strip))
    f\close()

build = (src, dst) ->
    getext = (p) -> select(2, path.splitext(p))
    nt = os.tmpname()

    switch getext(src)
        when ".moon"
            buildmoon(src, nt)
        when ".lua"
            buildlua(src, nt)
        when ".luac"
            fs.copy(src, dst)
{'fraction_non_alphanumeric': 0.1816250663834307, 'fraction_numerical': 0.01009028146574615, 'mean_word_length': 2.948637316561845, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4689292', 'n_tokens_mistral': 1410, 'n_tokens_neox': 1365, 'n_words': 360}