[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: luarocks selective require mapping
- From: Thomas Harning <harningt@...>
- Date: Sun, 17 Aug 2008 00:08:36 -0400
In preparing a rockspec for luajson, I stumbled into what I think
might be a problem for testing...
I want my test scripts to use the version of luajson that is in the
source tree (configured using package.path), however the
luarocks.require uses the package in the luarocks repository instead.
Is there any elegant mechanism to make luarocks work selectively to
fit the following situation...
* Try to use lua modules from a local path
* Try to use luarocks modules
* Use lua modules from default paths
My current mechanism is a hack of sorts:
==BEGIN
local old_require = require
require("luarocks.require")
local luarocks_require = require
function require(module, ...)
if module == "luajson" or module:match("^luajson%.") then
return old_require(module, ...)
end
return luarocks_require(module, ...)
end
== END
Where my default LUA_INIT is "require('luarocks.require')"...
Any better solutions?
Also: I originally used the ?/init.lua pattern for luajson, but it
appears that luarocks doesn't work with this, so instead I have to use
a json.lua outside of the json/ directory tree. Perhaps ?/init.lua
should be added to the capabilities of luarock's build system...