File: hook_require.lua

package info (click to toggle)
lua-json 1.3.4-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 688 kB
  • sloc: makefile: 71; php: 3
file content (16 lines) | stat: -rw-r--r-- 411 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
local os = require("os")
local old_require = require
if os.getenv('LUA_OLD_INIT') then
	local loadstring = loadstring or load
	assert(loadstring(os.getenv('LUA_OLD_INIT')))()
else
	require("luarocks.require")
end
local luarocks_require = require

function require(module, ...)
	if module == "json" or module:match("^json%.") then
		return old_require(module, ...)
	end
	return luarocks_require(module, ...)
end