{"action":"created","comment":{"url":"https://api.github.com/repos/google/web-starter-kit/pulls/comments/53360565","id":53360565,"diff_hunk":"@@ -0,0 +1,290 @@\n+/**\n+ *\n+ *  Web Starter Kit\n+ *  Copyright 2016 Google Inc. All rights reserved.\n+ *\n+ *  Licensed under the Apache License, Version 2.0 (the \"License\");\n+ *  you may not use this file except in compliance with the License.\n+ *  You may obtain a copy of the License at\n+ *\n+ *      https://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ *  Unless required by applicable law or agreed to in writing, software\n+ *  distributed under the License is distributed on an \"AS IS\" BASIS,\n+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ *  See the License for the specific language governing permissions and\n+ *  limitations under the License\n+ *\n+ */\n+\n+/* eslint-env node, mocha */\n+\n+'use strict';\n+\n+require('chai').should();\n+\n+const fs = require('fs');\n+const path = require('path');\n+const ncp = require('ncp');\n+const mkdirp = require('mkdirp');\n+const rimraf = require('rimraf');\n+const taskHelper = require('./helpers/task-helper');\n+\n+const VALID_TEST_FILES = path.join('test', 'data', 'valid-files');\n+const INVALID_TEST_FILES = path.join('test', 'data', 'invalid-files');\n+const VALID_TEST_FILES_2 = path.join('test', 'data', 'valid-files-2');\n+const TEST_OUTPUT_PATH = path.join('test', 'output');\n+const TEST_OUTPUT_SRC = path.join(TEST_OUTPUT_PATH, 'src');\n+const TEST_OUTPUT_DEST = path.join(TEST_OUTPUT_PATH, 'build');\n+\n+let watcherTask;\n+\n+// Use rimraf over del because it seems to work more reliably on Windows.\n+// Probably due to it's retries.\n+const deleteFiles = path => {\n+  return new Promise((resolve, reject) => {\n+    rimraf(path, err => {\n+      if (err) {\n+        reject(err);\n+        return;\n+      }\n+\n+      resolve();\n+    });\n+  })\n+  .catch(err => {\n+    console.log('deleteFiles() error ', err);\n+    throw err;\n+  });\n+};\n+\n+const copyFiles = (from, to) => {\n+  return new Promise((resolve, reject) => {\n+    ncp(from, to, err => {\n+      if (err) {\n+        reject(err);\n+        return;\n+      }\n+\n+      resolve();\n+    });\n+  })\n+  .catch(err => {\n+    console.log('copyFiles() error ', err);\n+    throw err;\n+  });\n+};\n+\n+const validateOutput = () => {\n+  // Get directories in build directory\n+  const folders = fs.readdirSync(TEST_OUTPUT_DEST);\n+  folders.forEach(folderName => {\n+    // Check if the source directory lives, if it doesn't we can ignore\n+    // the remaining output (i.e. old stuff that needs cleaning out)\n+    try {\n+      fs.lstatSync(path.join(TEST_OUTPUT_SRC, folderName));\n+    } catch (err) {\n+      // Path doesn't exist, we can ignore it\n+      return;\n+    }\n+\n+    const expectedOutputFileBuffer = fs.readFileSync(path.join(TEST_OUTPUT_SRC, folderName, 'output.json'));\n+    const expectedOutput = JSON.parse(expectedOutputFileBuffer.toString());\n+    expectedOutput.forEach(file => {\n+      const fullpath = path.join(TEST_OUTPUT_DEST, folderName, file);\n+      const pathstats = fs.lstatSync(fullpath);\n+      if (!pathstats) {\n+        throw new Error(`Expected output file could not be found: ${fullpath}`);\n+      }\n+\n+      if (pathstats.size <= 0) {\n+        throw new Error(`Output file has no contents: ${fullpath}`);\n+      }\n+    });\n+  });\n+};\n+\n+const performStep = (step, watcher) => {\n+  return new Promise(resolve => {\n+    let lastTimeout = Date.now();\n+    let callback = () => {\n+      lastTimeout = Date.now();\n+    };\n+    watcher.on('all', callback);\n+\n+    step();\n+\n+    let timeoutHandler = () => {\n+      if ((Date.now() - lastTimeout) > 2000) {\n+        watcher.removeListener('all', callback);\n+        resolve();\n+      } else {\n+        setTimeout(timeoutHandler, 1000);\n+      }\n+    };\n+\n+    timeoutHandler();\n+  });\n+};\n+\n+const stepOverEachStep = (steps, watcher) => {\n+  return steps.reduce((chainedPromise, nextStep) => {\n+    return chainedPromise.then(() => performStep(nextStep, watcher));\n+  }, Promise.resolve());\n+};\n+\n+const waitForWatcher = watcher => {\n+  return new Promise(resolve => {\n+    watcher.on('ready', () => {\n+      resolve();\n+    });\n+  });\n+};\n+\n+const performTest = (taskName, task, steps) => {\n+  // Start the tasks watching\n+  watcherTask = task.watch();\n+  if (!watcherTask) {\n+    return Promise.reject(new Error(`Nothing returned from the tasks watch() method. Is the result of gulp.watch returned in ${taskName}`));","path":"test/watch-test.js","position":148,"original_position":148,"commit_id":"932dc386bb1ac10269123336374d1e0c1d4055b4","original_commit_id":"932dc386bb1ac10269123336374d1e0c1d4055b4","user":{"login":"surma","id":234957,"avatar_url":"https://avatars.githubusercontent.com/u/234957?v=3","gravatar_id":"","url":"https://api.github.com/users/surma","html_url":"https://github.com/surma","followers_url":"https://api.github.com/users/surma/followers","following_url":"https://api.github.com/users/surma/following{/other_user}","gists_url":"https://api.github.com/users/surma/gists{/gist_id}","starred_url":"https://api.github.com/users/surma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/surma/subscriptions","organizations_url":"https://api.github.com/users/surma/orgs","repos_url":"https://api.github.com/users/surma/repos","events_url":"https://api.github.com/users/surma/events{/privacy}","received_events_url":"https://api.github.com/users/surma/received_events","type":"User","site_admin":false},"body":"add `?` to msg","created_at":"2016-02-18T18:42:28Z","updated_at":"2016-02-18T18:42:28Z","html_url":"https://github.com/google/web-starter-kit/pull/837#discussion_r53360565","pull_request_url":"https://api.github.com/repos/google/web-starter-kit/pulls/837","_links":{"self":{"href":"https://api.github.com/repos/google/web-starter-kit/pulls/comments/53360565"},"html":{"href":"https://github.com/google/web-starter-kit/pull/837#discussion_r53360565"},"pull_request":{"href":"https://api.github.com/repos/google/web-starter-kit/pulls/837"}}},"pull_request":{"url":"https://api.github.com/repos/google/web-starter-kit/pulls/837","id":59818860,"html_url":"https://github.com/google/web-starter-kit/pull/837","diff_url":"https://github.com/google/web-starter-kit/pull/837.diff","patch_url":"https://github.com/google/web-starter-kit/pull/837.patch","issue_url":"https://api.github.com/repos/google/web-starter-kit/issues/837","number":837,"state":"open","locked":false,"title":"Tests for watch tasks","user":{"login":"gauntface","id":139760,"avatar_url":"https://avatars.githubusercontent.com/u/139760?v=3","gravatar_id":"","url":"https://api.github.com/users/gauntface","html_url":"https://github.com/gauntface","followers_url":"https://api.github.com/users/gauntface/followers","following_url":"https://api.github.com/users/gauntface/following{/other_user}","gists_url":"https://api.github.com/users/gauntface/gists{/gist_id}","starred_url":"https://api.github.com/users/gauntface/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gauntface/subscriptions","organizations_url":"https://api.github.com/users/gauntface/orgs","repos_url":"https://api.github.com/users/gauntface/repos","events_url":"https://api.github.com/users/gauntface/events{/privacy}","received_events_url":"https://api.github.com/users/gauntface/received_events","type":"User","site_admin":false},"body":"@surma thoughts on this? Still worth doing?","created_at":"2016-02-18T15:53:39Z","updated_at":"2016-02-18T18:42:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5cab668db0323815ec8ba533f9ee290ef346bf2c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/google/web-starter-kit/pulls/837/commits","review_comments_url":"https://api.github.com/repos/google/web-starter-kit/pulls/837/comments","review_comment_url":"https://api.github.com/repos/google/web-starter-kit/pulls/comments{/number}","comments_url":"https://api.github.com/repos/google/web-starter-kit/issues/837/comments","statuses_url":"https://api.github.com/repos/google/web-starter-kit/statuses/932dc386bb1ac10269123336374d1e0c1d4055b4","head":{"label":"google:wsk2-watch-testing","ref":"wsk2-watch-testing","sha":"932dc386bb1ac10269123336374d1e0c1d4055b4","user":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":18511024,"name":"web-starter-kit","full_name":"google/web-starter-kit","owner":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/google/web-starter-kit","description":"Web Starter Kit - a workflow for multi-device websites","fork":false,"url":"https://api.github.com/repos/google/web-starter-kit","forks_url":"https://api.github.com/repos/google/web-starter-kit/forks","keys_url":"https://api.github.com/repos/google/web-starter-kit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/web-starter-kit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/web-starter-kit/teams","hooks_url":"https://api.github.com/repos/google/web-starter-kit/hooks","issue_events_url":"https://api.github.com/repos/google/web-starter-kit/issues/events{/number}","events_url":"https://api.github.com/repos/google/web-starter-kit/events","assignees_url":"https://api.github.com/repos/google/web-starter-kit/assignees{/user}","branches_url":"https://api.github.com/repos/google/web-starter-kit/branches{/branch}","tags_url":"https://api.github.com/repos/google/web-starter-kit/tags","blobs_url":"https://api.github.com/repos/google/web-starter-kit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/web-starter-kit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/web-starter-kit/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/web-starter-kit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/web-starter-kit/statuses/{sha}","languages_url":"https://api.github.com/repos/google/web-starter-kit/languages","stargazers_url":"https://api.github.com/repos/google/web-starter-kit/stargazers","contributors_url":"https://api.github.com/repos/google/web-starter-kit/contributors","subscribers_url":"https://api.github.com/repos/google/web-starter-kit/subscribers","subscription_url":"https://api.github.com/repos/google/web-starter-kit/subscription","commits_url":"https://api.github.com/repos/google/web-starter-kit/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/web-starter-kit/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/web-starter-kit/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/web-starter-kit/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/web-starter-kit/contents/{+path}","compare_url":"https://api.github.com/repos/google/web-starter-kit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/web-starter-kit/merges","archive_url":"https://api.github.com/repos/google/web-starter-kit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/web-starter-kit/downloads","issues_url":"https://api.github.com/repos/google/web-starter-kit/issues{/number}","pulls_url":"https://api.github.com/repos/google/web-starter-kit/pulls{/number}","milestones_url":"https://api.github.com/repos/google/web-starter-kit/milestones{/number}","notifications_url":"https://api.github.com/repos/google/web-starter-kit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/web-starter-kit/labels{/name}","releases_url":"https://api.github.com/repos/google/web-starter-kit/releases{/id}","deployments_url":"https://api.github.com/repos/google/web-starter-kit/deployments","created_at":"2014-04-07T08:45:18Z","updated_at":"2016-02-18T17:19:53Z","pushed_at":"2016-02-18T15:56:48Z","git_url":"git://github.com/google/web-starter-kit.git","ssh_url":"git@github.com:google/web-starter-kit.git","clone_url":"https://github.com/google/web-starter-kit.git","svn_url":"https://github.com/google/web-starter-kit","homepage":"http://developers.google.com/web/starter-kit","size":13836,"stargazers_count":12692,"watchers_count":12692,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":2031,"mirror_url":null,"open_issues_count":33,"forks":2031,"open_issues":33,"watchers":12692,"default_branch":"master"}},"base":{"label":"google:wsk2","ref":"wsk2","sha":"672049f54e1ee8a8b47901ff104dff44fe35634b","user":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":18511024,"name":"web-starter-kit","full_name":"google/web-starter-kit","owner":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/google/web-starter-kit","description":"Web Starter Kit - a workflow for multi-device websites","fork":false,"url":"https://api.github.com/repos/google/web-starter-kit","forks_url":"https://api.github.com/repos/google/web-starter-kit/forks","keys_url":"https://api.github.com/repos/google/web-starter-kit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/web-starter-kit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/web-starter-kit/teams","hooks_url":"https://api.github.com/repos/google/web-starter-kit/hooks","issue_events_url":"https://api.github.com/repos/google/web-starter-kit/issues/events{/number}","events_url":"https://api.github.com/repos/google/web-starter-kit/events","assignees_url":"https://api.github.com/repos/google/web-starter-kit/assignees{/user}","branches_url":"https://api.github.com/repos/google/web-starter-kit/branches{/branch}","tags_url":"https://api.github.com/repos/google/web-starter-kit/tags","blobs_url":"https://api.github.com/repos/google/web-starter-kit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/web-starter-kit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/web-starter-kit/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/web-starter-kit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/web-starter-kit/statuses/{sha}","languages_url":"https://api.github.com/repos/google/web-starter-kit/languages","stargazers_url":"https://api.github.com/repos/google/web-starter-kit/stargazers","contributors_url":"https://api.github.com/repos/google/web-starter-kit/contributors","subscribers_url":"https://api.github.com/repos/google/web-starter-kit/subscribers","subscription_url":"https://api.github.com/repos/google/web-starter-kit/subscription","commits_url":"https://api.github.com/repos/google/web-starter-kit/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/web-starter-kit/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/web-starter-kit/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/web-starter-kit/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/web-starter-kit/contents/{+path}","compare_url":"https://api.github.com/repos/google/web-starter-kit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/web-starter-kit/merges","archive_url":"https://api.github.com/repos/google/web-starter-kit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/web-starter-kit/downloads","issues_url":"https://api.github.com/repos/google/web-starter-kit/issues{/number}","pulls_url":"https://api.github.com/repos/google/web-starter-kit/pulls{/number}","milestones_url":"https://api.github.com/repos/google/web-starter-kit/milestones{/number}","notifications_url":"https://api.github.com/repos/google/web-starter-kit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/web-starter-kit/labels{/name}","releases_url":"https://api.github.com/repos/google/web-starter-kit/releases{/id}","deployments_url":"https://api.github.com/repos/google/web-starter-kit/deployments","created_at":"2014-04-07T08:45:18Z","updated_at":"2016-02-18T17:19:53Z","pushed_at":"2016-02-18T15:56:48Z","git_url":"git://github.com/google/web-starter-kit.git","ssh_url":"git@github.com:google/web-starter-kit.git","clone_url":"https://github.com/google/web-starter-kit.git","svn_url":"https://github.com/google/web-starter-kit","homepage":"http://developers.google.com/web/starter-kit","size":13836,"stargazers_count":12692,"watchers_count":12692,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":2031,"mirror_url":null,"open_issues_count":33,"forks":2031,"open_issues":33,"watchers":12692,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/google/web-starter-kit/pulls/837"},"html":{"href":"https://github.com/google/web-starter-kit/pull/837"},"issue":{"href":"https://api.github.com/repos/google/web-starter-kit/issues/837"},"comments":{"href":"https://api.github.com/repos/google/web-starter-kit/issues/837/comments"},"review_comments":{"href":"https://api.github.com/repos/google/web-starter-kit/pulls/837/comments"},"review_comment":{"href":"https://api.github.com/repos/google/web-starter-kit/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/google/web-starter-kit/pulls/837/commits"},"statuses":{"href":"https://api.github.com/repos/google/web-starter-kit/statuses/932dc386bb1ac10269123336374d1e0c1d4055b4"}}}}