aboutsummaryrefslogtreecommitdiffstats
path: root/make-feed.lua
diff options
context:
space:
mode:
authorgarret <garret@airmail.cc>2022-11-27 23:31:26 +0000
committergarret <garret@airmail.cc>2022-11-27 23:49:44 +0000
commit4b7c68ef3142801c2284f2ec1bbe8f403e20c39b (patch)
tree81b5501a095f3a5423ada80c6cbda10d625752dd /make-feed.lua
parentaca84223fbc3214cc5bf2b58b9b8ac8b0fa11de4 (diff)
downloaddepctrl-feedmaker-4b7c68ef3142801c2284f2ec1bbe8f403e20c39b.tar.gz
depctrl-feedmaker-4b7c68ef3142801c2284f2ec1bbe8f403e20c39b.tar.bz2
depctrl-feedmaker-4b7c68ef3142801c2284f2ec1bbe8f403e20c39b.zip
feedmaker: split file loading off into a function that throws error messages
as opposed to the script just crashing
Diffstat (limited to 'make-feed.lua')
-rwxr-xr-xmake-feed.lua26
1 files changed, 15 insertions, 11 deletions
diff --git a/make-feed.lua b/make-feed.lua
index 2b78493..94d9181 100755
--- a/make-feed.lua
+++ b/make-feed.lua
@@ -112,6 +112,17 @@ local function get_file_metadata(file)
return sha1, lastmodified
end
+local function run_file(file, extension)
+ local runner
+ if extension == "moon" then
+ runner = moonscript.loadfile(file)
+ else
+ runner = loadfile(file)
+ end
+ local worked, out = pcall(runner)
+ if not worked then err("error when loading "..file..": ".. out) end
+end
+
local function get_macro_metadata(file)
local meta = {file = file, name = nil, description = nil, version = nil, author = nil, namespace = nil, depctrl = nil, sha1 = nil, release = nil}
-- having all those nils in the table doesn't really do anything in terms of functionality, but it lets me see what i need to put in it
@@ -121,11 +132,8 @@ local function get_macro_metadata(file)
function include() end -- so it doesnt die with karaskel imports and such
- if meta.extension == "moon" then
- moonscript.loadfile(file)()
- else
- loadfile(file)()
- end
+ run_file(file, meta.extension)
+
-- script_name etc are now in our global scope
if config.macros.ignoreCondition() then
err(file .. ": ignored by config, skipping")
@@ -146,12 +154,8 @@ local function get_module_metadata(file)
meta.sha1, meta.release = get_file_metadata(file)
meta.basename, meta.extension = split_filename(file)
- if meta.extension == "moon" then
- moonscript.loadfile(file)()
- else
- loadfile(file)()
- end
- -- script_name etc are now in our global scope
+ run_file(file, meta.extension)
+
if config.modules.ignoreCondition() then
err(file .. ": ignored by config, skipping")
return nil