making 'no such task' errors a little nicer

This commit is contained in:
Jeremy Ashkenas
2010-02-17 20:37:30 -05:00
parent fbfa12c733
commit 8ff977dc65
2 changed files with 20 additions and 6 deletions

View File

@@ -6,6 +6,10 @@ coffee: require 'coffee-script'
tasks: {}
no_such_task: (task) ->
process.stdio.writeError('No such task: "' + task + '"\n')
process.exit(1)
# Mixin the Cake functionality.
process.mixin {
@@ -15,6 +19,7 @@ process.mixin {
# Invoke another task in the Cakefile.
invoke: (name) ->
no_such_task name unless tasks[name]
tasks[name].action()
}
@@ -35,6 +40,6 @@ exports.run: ->
eval coffee.compile source
return print_tasks() unless args.length
for arg in args
throw new Error('No such task: "' + arg + '"') unless tasks[arg]
no_such_task arg unless tasks[arg]
tasks[arg].action()