Skip to content

Commit 31c068a

Browse files
committed
Raise error when dir attribute is used without :root or :pwd.
1 parent 8bc14a6 commit 31c068a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

runx.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ def initialize(path, files)
6969
class NoTasksDefinedError < StandardError
7070
end
7171

72+
class DirAttributeError < StandardError
73+
def initialize(base)
74+
@base = base
75+
end
76+
77+
attr_reader :base
78+
end
79+
7280
class TaskManager
7381
def initialize
7482
@tasks = {}
@@ -153,6 +161,8 @@ def dir(base, relative = '.')
153161
Dir.pwd
154162
when :root
155163
@root_dir
164+
else
165+
raise DirAttributeError.new(base)
156166
end
157167
@task_dir = File.absolute_path(File.join(path, relative.to_s))
158168
end
@@ -290,6 +300,9 @@ def find_runfile
290300
rescue DirNotFoundError => e
291301
$stderr.puts "[runx] Error: Task #{e.task.name}: Directory not found: #{e.dir}."
292302
exit 1
303+
rescue DirAttributeError => e
304+
$stderr.puts "[runx] Error: Invalid attribute 'dir :#{e.base}'. Expected :root or :pwd."
305+
exit 1
293306
rescue Interrupt => e
294307
# Ignore interrupt and exit.
295308
end

0 commit comments

Comments
 (0)