moduleapi: module:provides called without an item makes a copy of the environment instead. Fixes warnings about non-existent globals
--- a/core/moduleapi.lua Sat Apr 27 14:59:00 2013 +0100
+++ b/core/moduleapi.lua Sat Apr 27 19:14:22 2013 +0200
@@ -319,7 +319,13 @@
end
function api:provides(name, item)
- if not item then item = self.environment; end
+ -- if not item then item = setmetatable({}, { __index = function(t,k) return rawget(self.environment, k); end }); end
+ if not item then
+ item = {}
+ for k,v in pairs(self.environment) do
+ if k ~= "module" then item[k] = v; end
+ end
+ end
if not item.name then
local item_name = self.name;
-- Strip a provider prefix to find the item name