{"action":"created","comment":{"url":"https://api.github.com/repos/tes/bosco/pulls/comments/76266969","id":76266969,"diff_hunk":"@@ -0,0 +1,77 @@\n+var spawn = require('child_process').spawn;\n+\n+module.exports = function(bosco) {\n+  return function(service, command, cwd, verbose, buildFinished) {\n+    bosco.log('Spawning ' + 'watch'.red + ' command for ' + service.name.blue + ': ' + command.log);\n+    var wc = spawn(process.env.SHELL, ['-c', command.command], cwd);\n+    var output = '';\n+    var errorOutput = '';\n+    var childError = null;\n+    var checkFinishedTimer;\n+    var overallTimeout;\n+    var waitingForOutput = true;\n+\n+    var watchBuildFinished = function(err, stdout, stderr) {\n+      clearTimeout(checkFinishedTimer);\n+      clearTimeout(overallTimeout);\n+      checkFinishedTimer = null;\n+      waitingForOutput = true;\n+      output = '';\n+      errorOutput = '';\n+      buildFinished(err, stdout, stderr);\n+    };\n+\n+    var checkFinished = function() {\n+      if (childError && childError !== true) {\n+        return watchBuildFinished(childError, output, errorOutput);\n+      }\n+      if (output.indexOf(command.ready) >= 0) {\n+        return watchBuildFinished(childError, output);\n+      }\n+      checkFinishedTimer = setTimeout(checkFinished, command.checkDelay);\n+    };\n+\n+    overallTimeout = setTimeout(function() {\n+      clearTimeout(checkFinishedTimer);\n+      bosco.error('Build timed out beyond ' + command.timeout / 1000 + ' seconds, likely an issue with the project build - you may need to check locally. Was looking for: ' + command.ready);\n+      childError = new Error('build timed out beyond ' + command.timeout / 1000 + ' seconds');\n+      wc.kill();\n+      return watchBuildFinished(childError, '', output);\n+    }, command.timeout);\n+\n+    wc.on('exit', function(code, signal) {\n+      if (!childError || childError === true) {\n+        // any exit of a watch process is an error.\n+        childError = new Error('Watch process exited with code ' + code + ' and signal ' + signal);\n+        childError.code = code;\n+        childError.signal = signal;\n+      }\n+      bosco.error('Watch'.red + ' command for ' + service.name.blue + ' died with code ' + code);\n+    });\n+\n+    wc.stdout.on('data', function(data) {\n+      if (waitingForOutput) {\n+        if (!checkFinishedTimer) checkFinished();\n+        waitingForOutput = false;\n+        bosco.log('Started build for service ' + service.name.blue + ' ...');\n+      }\n+      output += data.toString();","path":"src/ExternalBuilders/SpawnWatch.js","position":58,"original_position":58,"commit_id":"97f02fc856db1ed9bb32367a97eeda738f88f132","original_commit_id":"97f02fc856db1ed9bb32367a97eeda738f88f132","user":{"login":"geophree","id":239010,"avatar_url":"https://avatars.githubusercontent.com/u/239010?v=3","gravatar_id":"","url":"https://api.github.com/users/geophree","html_url":"https://github.com/geophree","followers_url":"https://api.github.com/users/geophree/followers","following_url":"https://api.github.com/users/geophree/following{/other_user}","gists_url":"https://api.github.com/users/geophree/gists{/gist_id}","starred_url":"https://api.github.com/users/geophree/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geophree/subscriptions","organizations_url":"https://api.github.com/users/geophree/orgs","repos_url":"https://api.github.com/users/geophree/repos","events_url":"https://api.github.com/users/geophree/events{/privacy}","received_events_url":"https://api.github.com/users/geophree/received_events","type":"User","site_admin":false},"body":"Also, I think you need to pull `calledReady` back in, you should stop storing output.  something like:\r\n```js\r\nif (!calledReady) output += data.toString();\r\n```","created_at":"2016-08-25T15:33:43Z","updated_at":"2016-08-25T15:33:43Z","html_url":"https://github.com/tes/bosco/pull/164#discussion_r76266969","pull_request_url":"https://api.github.com/repos/tes/bosco/pulls/164","_links":{"self":{"href":"https://api.github.com/repos/tes/bosco/pulls/comments/76266969"},"html":{"href":"https://github.com/tes/bosco/pull/164#discussion_r76266969"},"pull_request":{"href":"https://api.github.com/repos/tes/bosco/pulls/164"}}},"pull_request":{"url":"https://api.github.com/repos/tes/bosco/pulls/164","id":82679415,"html_url":"https://github.com/tes/bosco/pull/164","diff_url":"https://github.com/tes/bosco/pull/164.diff","patch_url":"https://github.com/tes/bosco/pull/164.patch","issue_url":"https://api.github.com/repos/tes/bosco/issues/164","number":164,"state":"open","locked":false,"title":"Refactor of external build to make the output cleaner","user":{"login":"cliftonc","id":239305,"avatar_url":"https://avatars.githubusercontent.com/u/239305?v=3","gravatar_id":"","url":"https://api.github.com/users/cliftonc","html_url":"https://github.com/cliftonc","followers_url":"https://api.github.com/users/cliftonc/followers","following_url":"https://api.github.com/users/cliftonc/following{/other_user}","gists_url":"https://api.github.com/users/cliftonc/gists{/gist_id}","starred_url":"https://api.github.com/users/cliftonc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cliftonc/subscriptions","organizations_url":"https://api.github.com/users/cliftonc/orgs","repos_url":"https://api.github.com/users/cliftonc/repos","events_url":"https://api.github.com/users/cliftonc/events{/privacy}","received_events_url":"https://api.github.com/users/cliftonc/received_events","type":"User","site_admin":false},"body":"Rolls up output changes from @bettiolo, should make ongoing watching and console output much more usable. ","created_at":"2016-08-25T08:45:52Z","updated_at":"2016-08-25T15:33:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a48b89d7dae2f612515d4ecd0f5d8979b5a3a829","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/tes/bosco/pulls/164/commits","review_comments_url":"https://api.github.com/repos/tes/bosco/pulls/164/comments","review_comment_url":"https://api.github.com/repos/tes/bosco/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tes/bosco/issues/164/comments","statuses_url":"https://api.github.com/repos/tes/bosco/statuses/97f02fc856db1ed9bb32367a97eeda738f88f132","head":{"label":"tes:build-refactor","ref":"build-refactor","sha":"97f02fc856db1ed9bb32367a97eeda738f88f132","user":{"login":"tes","id":7055819,"avatar_url":"https://avatars.githubusercontent.com/u/7055819?v=3","gravatar_id":"","url":"https://api.github.com/users/tes","html_url":"https://github.com/tes","followers_url":"https://api.github.com/users/tes/followers","following_url":"https://api.github.com/users/tes/following{/other_user}","gists_url":"https://api.github.com/users/tes/gists{/gist_id}","starred_url":"https://api.github.com/users/tes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tes/subscriptions","organizations_url":"https://api.github.com/users/tes/orgs","repos_url":"https://api.github.com/users/tes/repos","events_url":"https://api.github.com/users/tes/events{/privacy}","received_events_url":"https://api.github.com/users/tes/received_events","type":"Organization","site_admin":false},"repo":{"id":22931035,"name":"bosco","full_name":"tes/bosco","owner":{"login":"tes","id":7055819,"avatar_url":"https://avatars.githubusercontent.com/u/7055819?v=3","gravatar_id":"","url":"https://api.github.com/users/tes","html_url":"https://github.com/tes","followers_url":"https://api.github.com/users/tes/followers","following_url":"https://api.github.com/users/tes/following{/other_user}","gists_url":"https://api.github.com/users/tes/gists{/gist_id}","starred_url":"https://api.github.com/users/tes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tes/subscriptions","organizations_url":"https://api.github.com/users/tes/orgs","repos_url":"https://api.github.com/users/tes/repos","events_url":"https://api.github.com/users/tes/events{/privacy}","received_events_url":"https://api.github.com/users/tes/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tes/bosco","description":"A microservice helper","fork":false,"url":"https://api.github.com/repos/tes/bosco","forks_url":"https://api.github.com/repos/tes/bosco/forks","keys_url":"https://api.github.com/repos/tes/bosco/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tes/bosco/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tes/bosco/teams","hooks_url":"https://api.github.com/repos/tes/bosco/hooks","issue_events_url":"https://api.github.com/repos/tes/bosco/issues/events{/number}","events_url":"https://api.github.com/repos/tes/bosco/events","assignees_url":"https://api.github.com/repos/tes/bosco/assignees{/user}","branches_url":"https://api.github.com/repos/tes/bosco/branches{/branch}","tags_url":"https://api.github.com/repos/tes/bosco/tags","blobs_url":"https://api.github.com/repos/tes/bosco/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tes/bosco/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tes/bosco/git/refs{/sha}","trees_url":"https://api.github.com/repos/tes/bosco/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tes/bosco/statuses/{sha}","languages_url":"https://api.github.com/repos/tes/bosco/languages","stargazers_url":"https://api.github.com/repos/tes/bosco/stargazers","contributors_url":"https://api.github.com/repos/tes/bosco/contributors","subscribers_url":"https://api.github.com/repos/tes/bosco/subscribers","subscription_url":"https://api.github.com/repos/tes/bosco/subscription","commits_url":"https://api.github.com/repos/tes/bosco/commits{/sha}","git_commits_url":"https://api.github.com/repos/tes/bosco/git/commits{/sha}","comments_url":"https://api.github.com/repos/tes/bosco/comments{/number}","issue_comment_url":"https://api.github.com/repos/tes/bosco/issues/comments{/number}","contents_url":"https://api.github.com/repos/tes/bosco/contents/{+path}","compare_url":"https://api.github.com/repos/tes/bosco/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tes/bosco/merges","archive_url":"https://api.github.com/repos/tes/bosco/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tes/bosco/downloads","issues_url":"https://api.github.com/repos/tes/bosco/issues{/number}","pulls_url":"https://api.github.com/repos/tes/bosco/pulls{/number}","milestones_url":"https://api.github.com/repos/tes/bosco/milestones{/number}","notifications_url":"https://api.github.com/repos/tes/bosco/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tes/bosco/labels{/name}","releases_url":"https://api.github.com/repos/tes/bosco/releases{/id}","deployments_url":"https://api.github.com/repos/tes/bosco/deployments","created_at":"2014-08-13T20:57:35Z","updated_at":"2016-05-02T17:46:59Z","pushed_at":"2016-08-25T08:51:00Z","git_url":"git://github.com/tes/bosco.git","ssh_url":"git@github.com:tes/bosco.git","clone_url":"https://github.com/tes/bosco.git","svn_url":"https://github.com/tes/bosco","homepage":"","size":2897,"stargazers_count":43,"watchers_count":43,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":19,"mirror_url":null,"open_issues_count":27,"forks":19,"open_issues":27,"watchers":43,"default_branch":"master"}},"base":{"label":"tes:master","ref":"master","sha":"3f140e013af4bee24a1093b85ab8af3e836b320e","user":{"login":"tes","id":7055819,"avatar_url":"https://avatars.githubusercontent.com/u/7055819?v=3","gravatar_id":"","url":"https://api.github.com/users/tes","html_url":"https://github.com/tes","followers_url":"https://api.github.com/users/tes/followers","following_url":"https://api.github.com/users/tes/following{/other_user}","gists_url":"https://api.github.com/users/tes/gists{/gist_id}","starred_url":"https://api.github.com/users/tes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tes/subscriptions","organizations_url":"https://api.github.com/users/tes/orgs","repos_url":"https://api.github.com/users/tes/repos","events_url":"https://api.github.com/users/tes/events{/privacy}","received_events_url":"https://api.github.com/users/tes/received_events","type":"Organization","site_admin":false},"repo":{"id":22931035,"name":"bosco","full_name":"tes/bosco","owner":{"login":"tes","id":7055819,"avatar_url":"https://avatars.githubusercontent.com/u/7055819?v=3","gravatar_id":"","url":"https://api.github.com/users/tes","html_url":"https://github.com/tes","followers_url":"https://api.github.com/users/tes/followers","following_url":"https://api.github.com/users/tes/following{/other_user}","gists_url":"https://api.github.com/users/tes/gists{/gist_id}","starred_url":"https://api.github.com/users/tes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tes/subscriptions","organizations_url":"https://api.github.com/users/tes/orgs","repos_url":"https://api.github.com/users/tes/repos","events_url":"https://api.github.com/users/tes/events{/privacy}","received_events_url":"https://api.github.com/users/tes/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tes/bosco","description":"A microservice helper","fork":false,"url":"https://api.github.com/repos/tes/bosco","forks_url":"https://api.github.com/repos/tes/bosco/forks","keys_url":"https://api.github.com/repos/tes/bosco/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tes/bosco/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tes/bosco/teams","hooks_url":"https://api.github.com/repos/tes/bosco/hooks","issue_events_url":"https://api.github.com/repos/tes/bosco/issues/events{/number}","events_url":"https://api.github.com/repos/tes/bosco/events","assignees_url":"https://api.github.com/repos/tes/bosco/assignees{/user}","branches_url":"https://api.github.com/repos/tes/bosco/branches{/branch}","tags_url":"https://api.github.com/repos/tes/bosco/tags","blobs_url":"https://api.github.com/repos/tes/bosco/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tes/bosco/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tes/bosco/git/refs{/sha}","trees_url":"https://api.github.com/repos/tes/bosco/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tes/bosco/statuses/{sha}","languages_url":"https://api.github.com/repos/tes/bosco/languages","stargazers_url":"https://api.github.com/repos/tes/bosco/stargazers","contributors_url":"https://api.github.com/repos/tes/bosco/contributors","subscribers_url":"https://api.github.com/repos/tes/bosco/subscribers","subscription_url":"https://api.github.com/repos/tes/bosco/subscription","commits_url":"https://api.github.com/repos/tes/bosco/commits{/sha}","git_commits_url":"https://api.github.com/repos/tes/bosco/git/commits{/sha}","comments_url":"https://api.github.com/repos/tes/bosco/comments{/number}","issue_comment_url":"https://api.github.com/repos/tes/bosco/issues/comments{/number}","contents_url":"https://api.github.com/repos/tes/bosco/contents/{+path}","compare_url":"https://api.github.com/repos/tes/bosco/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tes/bosco/merges","archive_url":"https://api.github.com/repos/tes/bosco/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tes/bosco/downloads","issues_url":"https://api.github.com/repos/tes/bosco/issues{/number}","pulls_url":"https://api.github.com/repos/tes/bosco/pulls{/number}","milestones_url":"https://api.github.com/repos/tes/bosco/milestones{/number}","notifications_url":"https://api.github.com/repos/tes/bosco/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tes/bosco/labels{/name}","releases_url":"https://api.github.com/repos/tes/bosco/releases{/id}","deployments_url":"https://api.github.com/repos/tes/bosco/deployments","created_at":"2014-08-13T20:57:35Z","updated_at":"2016-05-02T17:46:59Z","pushed_at":"2016-08-25T08:51:00Z","git_url":"git://github.com/tes/bosco.git","ssh_url":"git@github.com:tes/bosco.git","clone_url":"https://github.com/tes/bosco.git","svn_url":"https://github.com/tes/bosco","homepage":"","size":2897,"stargazers_count":43,"watchers_count":43,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":19,"mirror_url":null,"open_issues_count":27,"forks":19,"open_issues":27,"watchers":43,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tes/bosco/pulls/164"},"html":{"href":"https://github.com/tes/bosco/pull/164"},"issue":{"href":"https://api.github.com/repos/tes/bosco/issues/164"},"comments":{"href":"https://api.github.com/repos/tes/bosco/issues/164/comments"},"review_comments":{"href":"https://api.github.com/repos/tes/bosco/pulls/164/comments"},"review_comment":{"href":"https://api.github.com/repos/tes/bosco/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tes/bosco/pulls/164/commits"},"statuses":{"href":"https://api.github.com/repos/tes/bosco/statuses/97f02fc856db1ed9bb32367a97eeda738f88f132"}}}}
{"actor":{"display_login":"geophree"}}