{"action":"created","comment":{"url":"https://api.github.com/repos/18F/pages-server/pulls/comments/51647391","id":51647391,"diff_hunk":"@@ -71,30 +71,44 @@ FilesHelper.prototype.after = function() {\n   return removeItems([this.dirs.lockDir, this.dirs.tempDir], 'rmdir');\n };\n \n-FilesHelper.prototype.createRepoDir = function(done) {\n+FilesHelper.prototype.createRepoDir = function() {\n   var helper = this;\n-  fs.mkdir(this.dirs.testRepoDir, '0700', function() {\n-    fs.writeFile(helper.files.configYml, '', done);\n+\n+  return new Promise(function(resolve, reject) {\n+    fs.mkdir(helper.dirs.testRepoDir, '0700', function(err) {\n+      if (err) {\n+        return reject(err);\n+      }\n+      fs.writeFile(helper.files.configYml, '', function(err) {\n+        if (err) {\n+          return reject(err);\n+        }\n+        resolve();\n+      });\n+    });\n   });\n };\n \n-FilesHelper.prototype.createRepoWithFiles = function(nameToContents, done) {\n+FilesHelper.prototype.createRepoWithFiles = function(nameToContents) {\n   var helper = this,\n-      filesRemaining,\n-      allDone;\n+      writeFile;\n \n   this.filesToDelete = Object.keys(nameToContents);\n-  filesRemaining = this.filesToDelete.length,\n-  allDone = function() {\n-    filesRemaining--;\n-    if (filesRemaining === 0) { done(); }\n+  writeFile = function(filename) {\n+    return new Promise(function(resolve, reject) {\n+      fs.writeFile(filename, nameToContents[filename], function(err) {\n+        if (err) {\n+          return reject(err);\n+        }\n+        resolve();\n+      });\n+    });\n   };\n \n-  this.createRepoDir(function() {\n-    helper.filesToDelete.map(function(name) {\n-      fs.writeFile(name, nameToContents[name], allDone);\n+  return this.createRepoDir()\n+    .then(function() {","path":"test/files-helper.js","position":52,"original_position":52,"commit_id":"0d3dfbc8df317f7988382d5f10d13fac2071a3ef","original_commit_id":"0d3dfbc8df317f7988382d5f10d13fac2071a3ef","user":{"login":"msecret","id":1701077,"avatar_url":"https://avatars.githubusercontent.com/u/1701077?v=3","gravatar_id":"","url":"https://api.github.com/users/msecret","html_url":"https://github.com/msecret","followers_url":"https://api.github.com/users/msecret/followers","following_url":"https://api.github.com/users/msecret/following{/other_user}","gists_url":"https://api.github.com/users/msecret/gists{/gist_id}","starred_url":"https://api.github.com/users/msecret/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/msecret/subscriptions","organizations_url":"https://api.github.com/users/msecret/orgs","repos_url":"https://api.github.com/users/msecret/repos","events_url":"https://api.github.com/users/msecret/events{/privacy}","received_events_url":"https://api.github.com/users/msecret/received_events","type":"User","site_admin":false},"body":"What if one of the promises fails? Should this have a catch block?","created_at":"2016-02-02T22:31:59Z","updated_at":"2016-02-02T22:31:59Z","html_url":"https://github.com/18F/pages-server/pull/29#discussion_r51647391","pull_request_url":"https://api.github.com/repos/18F/pages-server/pulls/29","_links":{"self":{"href":"https://api.github.com/repos/18F/pages-server/pulls/comments/51647391"},"html":{"href":"https://github.com/18F/pages-server/pull/29#discussion_r51647391"},"pull_request":{"href":"https://api.github.com/repos/18F/pages-server/pulls/29"}}},"pull_request":{"url":"https://api.github.com/repos/18F/pages-server/pulls/29","id":57895156,"html_url":"https://github.com/18F/pages-server/pull/29","diff_url":"https://github.com/18F/pages-server/pull/29.diff","patch_url":"https://github.com/18F/pages-server/pull/29.patch","issue_url":"https://api.github.com/repos/18F/pages-server/issues/29","number":29,"state":"open","locked":false,"title":"createRepoDir, createRepoWithFiles use Promises","user":{"login":"mbland","id":301547,"avatar_url":"https://avatars.githubusercontent.com/u/301547?v=3","gravatar_id":"","url":"https://api.github.com/users/mbland","html_url":"https://github.com/mbland","followers_url":"https://api.github.com/users/mbland/followers","following_url":"https://api.github.com/users/mbland/following{/other_user}","gists_url":"https://api.github.com/users/mbland/gists{/gist_id}","starred_url":"https://api.github.com/users/mbland/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbland/subscriptions","organizations_url":"https://api.github.com/users/mbland/orgs","repos_url":"https://api.github.com/users/mbland/repos","events_url":"https://api.github.com/users/mbland/events{/privacy}","received_events_url":"https://api.github.com/users/mbland/received_events","type":"User","site_admin":false},"body":"cc: @msecret @rogeruiz ","created_at":"2016-02-01T20:28:58Z","updated_at":"2016-02-02T22:31:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"541128748005e66674f1593d025b622106c8d74d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/18F/pages-server/pulls/29/commits","review_comments_url":"https://api.github.com/repos/18F/pages-server/pulls/29/comments","review_comment_url":"https://api.github.com/repos/18F/pages-server/pulls/comments{/number}","comments_url":"https://api.github.com/repos/18F/pages-server/issues/29/comments","statuses_url":"https://api.github.com/repos/18F/pages-server/statuses/0d3dfbc8df317f7988382d5f10d13fac2071a3ef","head":{"label":"18F:files-helper","ref":"files-helper","sha":"0d3dfbc8df317f7988382d5f10d13fac2071a3ef","user":{"login":"18F","id":6233994,"avatar_url":"https://avatars.githubusercontent.com/u/6233994?v=3","gravatar_id":"","url":"https://api.github.com/users/18F","html_url":"https://github.com/18F","followers_url":"https://api.github.com/users/18F/followers","following_url":"https://api.github.com/users/18F/following{/other_user}","gists_url":"https://api.github.com/users/18F/gists{/gist_id}","starred_url":"https://api.github.com/users/18F/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/18F/subscriptions","organizations_url":"https://api.github.com/users/18F/orgs","repos_url":"https://api.github.com/users/18F/repos","events_url":"https://api.github.com/users/18F/events{/privacy}","received_events_url":"https://api.github.com/users/18F/received_events","type":"Organization","site_admin":false},"repo":{"id":43040536,"name":"pages-server","full_name":"18F/pages-server","owner":{"login":"18F","id":6233994,"avatar_url":"https://avatars.githubusercontent.com/u/6233994?v=3","gravatar_id":"","url":"https://api.github.com/users/18F","html_url":"https://github.com/18F","followers_url":"https://api.github.com/users/18F/followers","following_url":"https://api.github.com/users/18F/following{/other_user}","gists_url":"https://api.github.com/users/18F/gists{/gist_id}","starred_url":"https://api.github.com/users/18F/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/18F/subscriptions","organizations_url":"https://api.github.com/users/18F/orgs","repos_url":"https://api.github.com/users/18F/repos","events_url":"https://api.github.com/users/18F/events{/privacy}","received_events_url":"https://api.github.com/users/18F/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/18F/pages-server","description":"Static website publishing server for 18F Pages","fork":false,"url":"https://api.github.com/repos/18F/pages-server","forks_url":"https://api.github.com/repos/18F/pages-server/forks","keys_url":"https://api.github.com/repos/18F/pages-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/18F/pages-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/18F/pages-server/teams","hooks_url":"https://api.github.com/repos/18F/pages-server/hooks","issue_events_url":"https://api.github.com/repos/18F/pages-server/issues/events{/number}","events_url":"https://api.github.com/repos/18F/pages-server/events","assignees_url":"https://api.github.com/repos/18F/pages-server/assignees{/user}","branches_url":"https://api.github.com/repos/18F/pages-server/branches{/branch}","tags_url":"https://api.github.com/repos/18F/pages-server/tags","blobs_url":"https://api.github.com/repos/18F/pages-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/18F/pages-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/18F/pages-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/18F/pages-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/18F/pages-server/statuses/{sha}","languages_url":"https://api.github.com/repos/18F/pages-server/languages","stargazers_url":"https://api.github.com/repos/18F/pages-server/stargazers","contributors_url":"https://api.github.com/repos/18F/pages-server/contributors","subscribers_url":"https://api.github.com/repos/18F/pages-server/subscribers","subscription_url":"https://api.github.com/repos/18F/pages-server/subscription","commits_url":"https://api.github.com/repos/18F/pages-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/18F/pages-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/18F/pages-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/18F/pages-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/18F/pages-server/contents/{+path}","compare_url":"https://api.github.com/repos/18F/pages-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/18F/pages-server/merges","archive_url":"https://api.github.com/repos/18F/pages-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/18F/pages-server/downloads","issues_url":"https://api.github.com/repos/18F/pages-server/issues{/number}","pulls_url":"https://api.github.com/repos/18F/pages-server/pulls{/number}","milestones_url":"https://api.github.com/repos/18F/pages-server/milestones{/number}","notifications_url":"https://api.github.com/repos/18F/pages-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/18F/pages-server/labels{/name}","releases_url":"https://api.github.com/repos/18F/pages-server/releases{/id}","deployments_url":"https://api.github.com/repos/18F/pages-server/deployments","created_at":"2015-09-24T02:42:21Z","updated_at":"2016-01-21T21:10:03Z","pushed_at":"2016-02-02T22:30:51Z","git_url":"git://github.com/18F/pages-server.git","ssh_url":"git@github.com:18F/pages-server.git","clone_url":"https://github.com/18F/pages-server.git","svn_url":"https://github.com/18F/pages-server","homepage":"https://www.npmjs.com/package/18f-pages-server","size":158,"stargazers_count":6,"watchers_count":6,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":8,"forks":1,"open_issues":8,"watchers":6,"default_branch":"master"}},"base":{"label":"18F:master","ref":"master","sha":"800faef04c2a878213463e612d3cbc7674b047b5","user":{"login":"18F","id":6233994,"avatar_url":"https://avatars.githubusercontent.com/u/6233994?v=3","gravatar_id":"","url":"https://api.github.com/users/18F","html_url":"https://github.com/18F","followers_url":"https://api.github.com/users/18F/followers","following_url":"https://api.github.com/users/18F/following{/other_user}","gists_url":"https://api.github.com/users/18F/gists{/gist_id}","starred_url":"https://api.github.com/users/18F/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/18F/subscriptions","organizations_url":"https://api.github.com/users/18F/orgs","repos_url":"https://api.github.com/users/18F/repos","events_url":"https://api.github.com/users/18F/events{/privacy}","received_events_url":"https://api.github.com/users/18F/received_events","type":"Organization","site_admin":false},"repo":{"id":43040536,"name":"pages-server","full_name":"18F/pages-server","owner":{"login":"18F","id":6233994,"avatar_url":"https://avatars.githubusercontent.com/u/6233994?v=3","gravatar_id":"","url":"https://api.github.com/users/18F","html_url":"https://github.com/18F","followers_url":"https://api.github.com/users/18F/followers","following_url":"https://api.github.com/users/18F/following{/other_user}","gists_url":"https://api.github.com/users/18F/gists{/gist_id}","starred_url":"https://api.github.com/users/18F/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/18F/subscriptions","organizations_url":"https://api.github.com/users/18F/orgs","repos_url":"https://api.github.com/users/18F/repos","events_url":"https://api.github.com/users/18F/events{/privacy}","received_events_url":"https://api.github.com/users/18F/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/18F/pages-server","description":"Static website publishing server for 18F Pages","fork":false,"url":"https://api.github.com/repos/18F/pages-server","forks_url":"https://api.github.com/repos/18F/pages-server/forks","keys_url":"https://api.github.com/repos/18F/pages-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/18F/pages-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/18F/pages-server/teams","hooks_url":"https://api.github.com/repos/18F/pages-server/hooks","issue_events_url":"https://api.github.com/repos/18F/pages-server/issues/events{/number}","events_url":"https://api.github.com/repos/18F/pages-server/events","assignees_url":"https://api.github.com/repos/18F/pages-server/assignees{/user}","branches_url":"https://api.github.com/repos/18F/pages-server/branches{/branch}","tags_url":"https://api.github.com/repos/18F/pages-server/tags","blobs_url":"https://api.github.com/repos/18F/pages-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/18F/pages-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/18F/pages-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/18F/pages-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/18F/pages-server/statuses/{sha}","languages_url":"https://api.github.com/repos/18F/pages-server/languages","stargazers_url":"https://api.github.com/repos/18F/pages-server/stargazers","contributors_url":"https://api.github.com/repos/18F/pages-server/contributors","subscribers_url":"https://api.github.com/repos/18F/pages-server/subscribers","subscription_url":"https://api.github.com/repos/18F/pages-server/subscription","commits_url":"https://api.github.com/repos/18F/pages-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/18F/pages-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/18F/pages-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/18F/pages-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/18F/pages-server/contents/{+path}","compare_url":"https://api.github.com/repos/18F/pages-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/18F/pages-server/merges","archive_url":"https://api.github.com/repos/18F/pages-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/18F/pages-server/downloads","issues_url":"https://api.github.com/repos/18F/pages-server/issues{/number}","pulls_url":"https://api.github.com/repos/18F/pages-server/pulls{/number}","milestones_url":"https://api.github.com/repos/18F/pages-server/milestones{/number}","notifications_url":"https://api.github.com/repos/18F/pages-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/18F/pages-server/labels{/name}","releases_url":"https://api.github.com/repos/18F/pages-server/releases{/id}","deployments_url":"https://api.github.com/repos/18F/pages-server/deployments","created_at":"2015-09-24T02:42:21Z","updated_at":"2016-01-21T21:10:03Z","pushed_at":"2016-02-02T22:30:51Z","git_url":"git://github.com/18F/pages-server.git","ssh_url":"git@github.com:18F/pages-server.git","clone_url":"https://github.com/18F/pages-server.git","svn_url":"https://github.com/18F/pages-server","homepage":"https://www.npmjs.com/package/18f-pages-server","size":158,"stargazers_count":6,"watchers_count":6,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":8,"forks":1,"open_issues":8,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/18F/pages-server/pulls/29"},"html":{"href":"https://github.com/18F/pages-server/pull/29"},"issue":{"href":"https://api.github.com/repos/18F/pages-server/issues/29"},"comments":{"href":"https://api.github.com/repos/18F/pages-server/issues/29/comments"},"review_comments":{"href":"https://api.github.com/repos/18F/pages-server/pulls/29/comments"},"review_comment":{"href":"https://api.github.com/repos/18F/pages-server/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/18F/pages-server/pulls/29/commits"},"statuses":{"href":"https://api.github.com/repos/18F/pages-server/statuses/0d3dfbc8df317f7988382d5f10d13fac2071a3ef"}}}}