Skip to content

Commit

Permalink
v3.3.2. Improvement.
Browse files Browse the repository at this point in the history
  • Loading branch information
balupton committed Nov 19, 2013
1 parent d80089e commit c1ce0ae
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 2 deletions.
3 changes: 3 additions & 0 deletions History.md
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,8 @@
## History ## History


- v3.3.2 November 19, 2013
- Don't add or create empty tasks and groups

- v3.3.1 November 6, 2013 - v3.3.1 November 6, 2013
- Fixed child event bubbling by using duck typing (regression since v3.3.0) - Fixed child event bubbling by using duck typing (regression since v3.3.0)
- Better error handling on uncaught task exceptions - Better error handling on uncaught task exceptions
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Original file line Diff line number Diff line change
@@ -1,7 +1,7 @@
{ {
"title": "TaskGroup", "title": "TaskGroup",
"name": "taskgroup", "name": "taskgroup",
"version": "3.3.1", "version": "3.3.2",
"description": "Group together synchronous and asynchronous tasks and execute them with support for concurrency, naming, and nesting.", "description": "Group together synchronous and asynchronous tasks and execute them with support for concurrency, naming, and nesting.",
"homepage": "https://github.com/bevry/taskgroup", "homepage": "https://github.com/bevry/taskgroup",
"license": { "license": {
Expand Down
5 changes: 5 additions & 0 deletions src/lib/taskgroup.coffee
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -337,6 +337,9 @@ class TaskGroup extends EventEmitter
# Prepare # Prepare
me = @ me = @


# Only add the item if it exists
return null unless item

# Link our item to ourself # Link our item to ourself
item.setConfig({parent: @}) item.setConfig({parent: @})


Expand Down Expand Up @@ -382,6 +385,7 @@ class TaskGroup extends EventEmitter




createTask: (args...) -> createTask: (args...) ->
return null unless args[0]
return args[0] if args[0]?.type is 'task' return args[0] if args[0]?.type is 'task'
return new Task(args...) return new Task(args...)


Expand All @@ -394,6 +398,7 @@ class TaskGroup extends EventEmitter




createGroup: (args...) -> createGroup: (args...) ->
return null unless args[0]
return args[0] if args[0]?.type is 'taskgroup' return args[0] if args[0]?.type is 'taskgroup'
return new TaskGroup(args...) return new TaskGroup(args...)


Expand Down
40 changes: 39 additions & 1 deletion src/test/taskgroup-test.coffee
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ joe.describe 'taskgroup', (describe,it) ->
# Test Runner # Test Runner
joe.describe 'inline', (describe,it) -> joe.describe 'inline', (describe,it) ->
# Work # Work
it 'should work', (done) -> it 'should work (format 1)', (done) ->
checks = [] checks = []


tasks = new TaskGroup 'my tests', (addGroup,addTask) -> tasks = new TaskGroup 'my tests', (addGroup,addTask) ->
Expand Down Expand Up @@ -445,4 +445,42 @@ joe.describe 'inline', (describe,it) ->
expect(checks.length, 'checks').to.eql(4) expect(checks.length, 'checks').to.eql(4)


done() done()
# Work
it 'should work (format 2)', (done) ->
checks = []

tasks = new TaskGroup().run()

tasks.addTask 'my task', (complete) ->
checks.push('my task 1')
expect(@config.name).to.eql('my task')
expect(tasks.remaining.length).to.eql(1)
expect(tasks.running).to.eql(1)
wait 500, ->
checks.push('my task 2')
expect(tasks.remaining.length).to.eql(1)
expect(tasks.running).to.eql(1)
complete()

tasks.addGroup 'my group', ->
checks.push('my group')
expect(@config.name).to.eql('my group')
expect(tasks.remaining.length, 'my group remaining').to.eql(0)
expect(tasks.running).to.eql(1)

@addTask 'my second task', ->
checks.push('my second task')
expect(@config.name).to.eql('my second task')
expect(tasks.remaining.length, 'my second task remaining').to.eql(0)
expect(tasks.running).to.eql(1)

tasks.on 'complete', (err) ->
console.log(err) if err
expect(err).to.eql(null)

console.log(checks) if checks.length isnt 4
expect(checks.length, 'checks').to.eql(4)

done()



0 comments on commit c1ce0ae

Please sign in to comment.