2024-04-12 22:30:16 +02:00
|
|
|
-- local l = require("pandoc.logging")
|
|
|
|
local json = pandoc.json
|
|
|
|
|
|
|
|
assert(#arg > 1, "\n" ..
|
|
|
|
"[ERROR] usage: pandoc lua sitemap.lua <destination file> <input file>...")
|
2024-04-22 23:44:54 +02:00
|
|
|
local destination_filepath = arg[1]
|
|
|
|
local filepaths_arr = {}
|
|
|
|
for i = 2, #arg do
|
|
|
|
table.insert(filepaths_arr, arg[i])
|
2024-04-12 22:30:16 +02:00
|
|
|
end
|
|
|
|
|
2024-04-22 23:44:54 +02:00
|
|
|
local data = json.encode(filepaths_arr)
|
2024-04-12 22:30:16 +02:00
|
|
|
local f = io.open(destination_filepath)
|
|
|
|
if f == nil or f:read("a") ~= data then
|
|
|
|
local f = assert(io.open(destination_filepath, "w"), "\n" ..
|
|
|
|
"[ERROR] could not open " .. destination_filepath .. " for writing")
|
|
|
|
f:write(data)
|
|
|
|
f:close()
|
|
|
|
end
|