64 lines
2.0 KiB
Lua
64 lines
2.0 KiB
Lua
-- Makes bundle and min distribution
|
|
|
|
-- Adds local luarocks modules
|
|
local optpath = "./opt/share/lua/5.4/"
|
|
package.path = optpath .. "?.lua;" .. package.path
|
|
|
|
-- Adds Lua custom extensions
|
|
local lua_dog = require("dog")
|
|
lua_dog.import()
|
|
|
|
-- Makes distribution
|
|
local function make_dist(name, bundle)
|
|
|
|
-- Chomps file
|
|
local function chomp(str)
|
|
str = string.readtext(str):strip()
|
|
return "\n" .. str .. "\n"
|
|
end
|
|
|
|
-- Defaults to true
|
|
bundle = (bundle == nil or bundle == true)
|
|
|
|
-- Variables
|
|
local dist = pandoc.path.join({"dist", name})
|
|
local fnl = chomp(optpath .. "fennel.lua"):gsub("\nreturn mod\n", "\nlocal fnl = mod\n")
|
|
local dog = chomp(optpath .. "dog.lua"):gsub("\nreturn dog\n", "")
|
|
local nat = chomp("src/natural.lua"):gsub("\nreturn nat\n", "")
|
|
local lit = chomp("src/literate.lua"):gsub("#locale%(%)", ("src/locale.yaml"):readtext())
|
|
local pan = chomp("src/pandoc.lua")
|
|
local license = string.strip([[
|
|
Computable Pandoc:
|
|
(C) 2023 perro hi@perrotuerto.blog
|
|
License: GPLv3 https://git.cuates.net/perro/computable-pandoc/src/branch/no-masters/LICENSE.txt
|
|
Source: https://git.cuates.net/perro/computable-pandoc
|
|
]])
|
|
local extralicense = string.strip([[
|
|
Computable Pandoc & Fennel Bundle:
|
|
A Pandoc filter for literate and natural programming
|
|
]] .. license .. "\n" .. [[
|
|
Fennel:
|
|
(C) 2016-2023 Calvin Rose and contributors
|
|
License: MIT License https://git.sr.ht/~technomancy/fennel/tree/main/item/LICENSE
|
|
Source: https://sr.ht/~technomancy/fennel or https://github.com/bakpakin/Fennel/issues
|
|
Website: https://fennel-lang.org
|
|
]])
|
|
|
|
-- Bundles Fennel and Computable Pandoc
|
|
local file = io.open(dist, "w")
|
|
if bundle then
|
|
file:write("--[[\n", extralicense, "\n]]--\n")
|
|
file:write(fnl, dog, nat)
|
|
else
|
|
file:write("--[[\n", license, "\n]]--\n")
|
|
file:write('\nrequire "fennel"\nrequire "nat"\n')
|
|
file:write('\nlocal lua_dog = require("dog")\n')
|
|
end
|
|
file:write('\ndog.import()\n')
|
|
file:write(lit, pan)
|
|
file:close()
|
|
end
|
|
|
|
make_dist("lin.bundle.lua")
|
|
make_dist("lin.min.lua", false)
|