Skip to content

Commit

Permalink
more work, got cakefiles runnins, can now think about how to test!
Browse files Browse the repository at this point in the history
  • Loading branch information
maxtaco committed Jan 24, 2012
1 parent 332fff2 commit af36682
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 14 deletions.
6 changes: 6 additions & 0 deletions Cakefile
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -246,3 +246,9 @@ task 'test:browser', 'run the test suite against the merged browser script', ->
global.testingBrowser = yes global.testingBrowser = yes
(-> eval source).call result (-> eval source).call result
runTests result.CoffeeScript runTests result.CoffeeScript

atask 'test:acake', 'run a test for Cakefile async', (opts,cb) ->
console.log "start sleep"
await setTimeout defer(), 1000
console.log "end sleep"
cb()
101 changes: 90 additions & 11 deletions lib/coffee-script/cake.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions src/cake.coffee
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -29,16 +29,23 @@ helpers.extend global,
[action, description] = [description, action] unless action [action, description] = [description, action] unless action
tasks[name] = {name, description, action, async} tasks[name] = {name, description, action, async}


atask: (name, description, action) ->
task name, description, action, true

# Define an option that the Cakefile accepts. The parsed options hash, # Define an option that the Cakefile accepts. The parsed options hash,
# containing all of the command-line options passed, will be made available # containing all of the command-line options passed, will be made available
# as the first argument to the action. # as the first argument to the action.
option: (letter, flag, description) -> option: (letter, flag, description) ->
switches.push [letter, flag, description] switches.push [letter, flag, description]


# Invoke another task in the current Cakefile. # Invoke another task in the current Cakefile.
invoke: (name) -> invoke: (name, cb) ->
missingTask name unless (t = tasks[name]) missingTask name unless (t = tasks[name])
t.action options if t.async
await t.action(options, defer())
else
t.action options
cb()


# Run `cake`. Executes all of the tasks you pass, in order. Note that Node's # Run `cake`. Executes all of the tasks you pass, in order. Note that Node's
# asynchrony may cause tasks to execute in a different order than you'd expect. # asynchrony may cause tasks to execute in a different order than you'd expect.
Expand All @@ -56,7 +63,7 @@ exports.run = (cb) ->
catch e catch e
return fatalError "#{e}" return fatalError "#{e}"
for arg in options.arguments for arg in options.arguments
invoke arg await invoke(arg,defer())


# Display the list of Cake tasks in a format similar to `rake -T` # Display the list of Cake tasks in a format similar to `rake -T`
printTasks = -> printTasks = ->
Expand Down

0 comments on commit af36682

Please sign in to comment.