Better cwd handling.

This commit is contained in:
David Given
2016-06-29 13:58:38 +02:00
parent c8711628ab
commit 90764320bb
2 changed files with 18 additions and 2 deletions

View File

@@ -358,6 +358,7 @@ local function definerule(rulename, types, cb)
end
types.name = { type="string" }
types.cwd = { type="string", optional=true }
for propname, typespec in pairs(types) do
if not typeconverters[typespec.type] then
@@ -366,6 +367,7 @@ local function definerule(rulename, types, cb)
end
end
local rulecwd = cwd
local rule = function(e)
local args = {}
for propname, typespec in pairs(types) do
@@ -388,8 +390,16 @@ local function definerule(rulename, types, cb)
args.environment = environment
args.fullname = cwd.."+"..args.name
args.rulecwd = rulecwd
if not args.cwd then
args.cwd = cwd
end
local oldcwd = cwd
cwd = rulecwd
local result = cb(args) or {}
cwd = oldcwd
result.is = result.is or {}
result.is[rulename] = true
result.fullname = args.fullname