Skip to content

Commit 45112e8

Browse files
committed
Raise error if Runfile exists but no tasks have been defined.
1 parent 0f73c96 commit 45112e8

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

runx.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ def initialize(path, files)
5656
attr_reader :path, :files
5757
end
5858

59+
class NoTasksDefinedError < StandardError
60+
end
61+
5962
class TaskManager
6063
def initialize
6164
@tasks = {}
@@ -66,6 +69,7 @@ def load(file)
6669
context = TaskContext.new(dir, self)
6770
context.instance_eval(File.read(file), file)
6871
@tasks.merge!(context.tasks)
72+
raise NoTasksDefinedError if @tasks.empty?
6973
end
7074

7175
def show_help
@@ -234,6 +238,9 @@ def find_runfile
234238
rescue MultipleRunfileError => e
235239
$stderr.puts "[runx] Error: Multiple Runfiles found in #{e.path}: #{e.files.join(', ')}."
236240
exit 1
241+
rescue NoTasksDefinedError => e
242+
$stderr.puts '[runx] Error: No tasks defined. See https://github.com/schmich/runx#usage.'
243+
exit 1
237244
rescue TaskNotFoundError => e
238245
$stderr.puts "[runx] Error: Task '#{e.name}' not found."
239246
exit 1

0 commit comments

Comments
 (0)