Skip to content

Instantly share code, notes, and snippets.

Created February 11, 2012 21:53
What would you like to do?
Run tasks sequentially in a Cakefile
task 'sample_task', sample_task = (callback) ->
doSomethingAndRunCallbackAfter callback
task 'setup', 'All: Import all data and run webserver', ->
tasks = [install, pre_populate, populate_couch, graph_sync, server]
runSequentially = (currentTask, otherTasks...) ->
currentTask ->
if otherTasks.length
runSequentially otherTasks...
runSequentially tasks...
Copy link

All the tasks (install, pre_populate, etc.) are implemented as named functions as arguments to "task" and take a callback that will be executed after they complete.

I like the Lisp-style way of using a splat to get the first and next tasks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment