{"action":"created","issue":{"url":"https://api.github.com/repos/orchestrator/orchestrator/issues/71","labels_url":"https://api.github.com/repos/orchestrator/orchestrator/issues/71/labels{/name}","comments_url":"https://api.github.com/repos/orchestrator/orchestrator/issues/71/comments","events_url":"https://api.github.com/repos/orchestrator/orchestrator/issues/71/events","html_url":"https://github.com/orchestrator/orchestrator/issues/71","id":129898716,"number":71,"title":"doneCallback is persisted and called after other tasks with no callback","user":{"login":"jsocol","id":180459,"avatar_url":"https://avatars.githubusercontent.com/u/180459?v=3","gravatar_id":"","url":"https://api.github.com/users/jsocol","html_url":"https://github.com/jsocol","followers_url":"https://api.github.com/users/jsocol/followers","following_url":"https://api.github.com/users/jsocol/following{/other_user}","gists_url":"https://api.github.com/users/jsocol/gists{/gist_id}","starred_url":"https://api.github.com/users/jsocol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsocol/subscriptions","organizations_url":"https://api.github.com/users/jsocol/orgs","repos_url":"https://api.github.com/users/jsocol/repos","events_url":"https://api.github.com/users/jsocol/events{/privacy}","received_events_url":"https://api.github.com/users/jsocol/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-01-29T22:20:30Z","updated_at":"2016-01-31T04:23:14Z","closed_at":null,"body":"We ran into this problem writing tests for Gulp tasks, but here's an example that demonstrates the problem with only Orchestrator:\r\n\r\n```js\r\n'use strict';\r\n\r\nvar Orchestrator = require('orchestrator');\r\nvar orchestrator = new Orchestrator();\r\n\r\norchestrator.add('foo', function() {\r\n  // Doesn't matter.\r\n});\r\n\r\norchestrator.start('foo', function doneCB(err) {\r\n  console.log('done with foo');\r\n});\r\n\r\norchestrator.start('foo');\r\n```\r\n\r\nWhen run, the output is\r\n\r\n```\r\n$ node example.js\r\ndone with foo\r\ndone with foo\r\n```\r\n\r\n(The problem we had was using a jasmine `done()` call in the `doneCallback`, which would end up getting called multiple times, e.g.\r\n\r\n```js\r\ndescribe('foo', function() {\r\n  it('should do', function(done) {\r\n    gulp.start('foo-task', function fooCB() {\r\n      done();\r\n    });\r\n  });\r\n  it('does another thing', function() {\r\n    gulp.start('bar-task');  // fooCB gets called again, maybe, later\r\n  });\r\n});\r\n```\r\n)\r\n\r\nSince `Orchestrator` already inherits from `EventEmitter`, `doneCallback` could be replaced with `.once()` and an internal event name, e.g.:\r\n\r\n```js\r\n// index.js L79\r\nthis.once('::complete', lastTask);\r\n\r\n// index.js L150\r\nthis.emit('::complete', err);\r\n```\r\n\r\nIf that's something you'd be OK with, I'd be happy to open a PR."},"comment":{"url":"https://api.github.com/repos/orchestrator/orchestrator/issues/comments/177382657","html_url":"https://github.com/orchestrator/orchestrator/issues/71#issuecomment-177382657","issue_url":"https://api.github.com/repos/orchestrator/orchestrator/issues/71","id":177382657,"user":{"login":"robrich","id":664956,"avatar_url":"https://avatars.githubusercontent.com/u/664956?v=3","gravatar_id":"","url":"https://api.github.com/users/robrich","html_url":"https://github.com/robrich","followers_url":"https://api.github.com/users/robrich/followers","following_url":"https://api.github.com/users/robrich/following{/other_user}","gists_url":"https://api.github.com/users/robrich/gists{/gist_id}","starred_url":"https://api.github.com/users/robrich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robrich/subscriptions","organizations_url":"https://api.github.com/users/robrich/orgs","repos_url":"https://api.github.com/users/robrich/repos","events_url":"https://api.github.com/users/robrich/events{/privacy}","received_events_url":"https://api.github.com/users/robrich/received_events","type":"User","site_admin":false},"created_at":"2016-01-31T04:23:14Z","updated_at":"2016-01-31T04:23:14Z","body":"Thanks for the detailed description.  This is a duplicate of https://github.com/orchestrator/orchestrator/issues/15."}}