ferron

Ferron is a fast and simple static website generator made with Lua.
Log | Files | Refs | Submodules | README | LICENSE

commit 7a6ee6bbca6f5667ac4ae89e63cbfb6f1d2ca4bf
parent e27659c0bc39dd7bb5166a2eca05635d04a23aa6
Author: Hugo Soucy <hugo@soucy.cc>
Date:   Mon, 17 Dec 2018 22:01:53 -0500

Fix a link bug if list is empty

Diffstat:
Mferron/link.lua | 20+++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/ferron/link.lua b/ferron/link.lua @@ -50,18 +50,20 @@ function link.makerewritemap() if path.isfile(links_db) then links = json.decode(fileutils.pullfilecontent(links_db)) - -- Create an empty map file - fileutils.pushfilecontent(links_map, "") + if links then + -- Create an empty map file + fileutils.pushfilecontent(links_map, "") - -- Open it - map, map_err = io.open(links_map, "a") + -- Open it + map, map_err = io.open(links_map, "a") - for k, v in pairs(links) do - map:write(v .. " " .. k, "\n") - end + for k, v in pairs(links) do + map:write(v .. " " .. k, "\n") + end - -- Close it when it's done - map:close() + -- Close it when it's done + map:close() + end end end