Skip to content

Commit e06f68d

Browse files
committed
Reduce the variables exposed in the Runfile environment.
1 parent 5b34b72 commit e06f68d

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

runx.rb

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ def run_task(name, *args)
122122

123123
def load_tasks(file)
124124
context = TaskContext.new(File.dirname(file), self)
125-
InstanceBinding.for(context).eval(File.read(file), file)
125+
proxy = TaskContextProxy.new(context)
126+
InstanceBinding.for(proxy).eval(File.read(file), file)
126127
context.tasks
127128
end
128129
end
@@ -138,6 +139,28 @@ def self.create
138139
end
139140
end
140141

142+
class TaskContextProxy
143+
def initialize(real)
144+
@_ = real
145+
end
146+
147+
def auto
148+
@_.auto
149+
end
150+
151+
def dir(base, relative = '.')
152+
@_.dir(base, relative)
153+
end
154+
155+
def doc(doc)
156+
@_.doc(doc)
157+
end
158+
159+
def run(*args, &block)
160+
@_.run(*args, &block)
161+
end
162+
end
163+
141164
class TaskContext
142165
def initialize(root_dir, manager)
143166
@tasks = {}

0 commit comments

Comments
 (0)