Skip to content

Instantly share code, notes, and snippets.

@topfunky
Created February 11, 2012 21:53
Show Gist options
  • Save topfunky/1804467 to your computer and use it in GitHub Desktop.
Save topfunky/1804467 to your computer and use it in GitHub Desktop.
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...
@topfunky
Copy link
Author

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