From 22e37d6e6e2278764163fc53a989352a3ea77bfd Mon Sep 17 00:00:00 2001 From: garret Date: Mon, 28 Nov 2022 23:30:01 +0000 Subject: 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 --- make-feed.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'make-feed.lua') 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) -- cgit v1.2.3-70-g09d2