diff options
author | garret <garret@airmail.cc> | 2022-11-28 23:30:01 +0000 |
---|---|---|
committer | garret <garret@airmail.cc> | 2022-11-28 23:30:01 +0000 |
commit | 22e37d6e6e2278764163fc53a989352a3ea77bfd (patch) | |
tree | 9a299f5e4d5ed654753565258ad0064c68796b05 /make-feed.lua | |
parent | 1a39db987a81fee0bc2e12022630ff68fcb63230 (diff) | |
download | depctrl-feedmaker-22e37d6e6e2278764163fc53a989352a3ea77bfd.tar.gz depctrl-feedmaker-22e37d6e6e2278764163fc53a989352a3ea77bfd.tar.bz2 depctrl-feedmaker-22e37d6e6e2278764163fc53a989352a3ea77bfd.zip |
make scripts use custom require that doesn't care about not finding it
initial function and advice provided by regex man
Co-authored-by: 9382 <omnomaidan@gmail.com>
Diffstat (limited to 'make-feed.lua')
-rwxr-xr-x | make-feed.lua | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/make-feed.lua b/make-feed.lua index 554d61e..17c06c2 100755 --- a/make-feed.lua +++ b/make-feed.lua @@ -114,6 +114,17 @@ end local function run_file(file, extension) local runner + local old_require = require + _G.require = function(obj) + local got, lib = pcall(old_require, obj) + if got then + return lib + else + err(file .. " tried to require " .. obj .. " but couldn't. skipping and hoping it won't matter.") + return {} --Some default value, hopefully it should be fine with it + end + end + if extension == "moon" then runner = moonscript.loadfile(file) else @@ -121,6 +132,7 @@ local function run_file(file, extension) end local worked, out = pcall(runner) if not worked then err("error when loading "..file..": ".. out) end + _G.require = old_require end local function get_macro_metadata(file) |