{"action":"created","comment":{"url":"https://api.github.com/repos/angular/angular/pulls/comments/29953915","id":29953915,"diff_hunk":"@@ -1,56 +1,47 @@\n /// <reference path=\"./broccoli-writer.d.ts\" />\n /// <reference path=\"../typings/node/node.d.ts\" />\n /// <reference path=\"../typings/fs-extra/fs-extra.d.ts\" />\n+/// <reference path=\"./ts2dart.d.ts\" />\n \n import Writer = require('broccoli-writer');\n import fs = require('fs');\n import fse = require('fs-extra');\n import path = require('path');\n import ts2dart = require('ts2dart');\n+import {wrapDiffingPlugin, DiffingBroccoliPlugin, DiffResult} from './diffing-broccoli-plugin';\n \n-type Set = {\n-  [s: string]: boolean\n-};\n+class DiffingTypeScriptToDartTranspiler implements DiffingBroccoliPlugin {\n+  static includeExtensions = ['.js', '.ts'];\n \n-class TypeScriptToDartTranspiler extends Writer {\n-  constructor(private inputTree, private includePattern = /\\.(js|ts)$/) { super(); }\n+  private ts2dartOpts;\n+  private basePath: string;\n \n-  write(readTree, destDir): Promise<void> {\n-    return readTree(this.inputTree).then(dir => this.transpile(dir, destDir));\n+  constructor(public inputPath: string, public cachePath: string, public options) {\n+    this.basePath = (options && options.basePath) || '';\n+    this.ts2dartOpts = {generateLibraryName: true, generateSourceMap: false, basePath: inputPath};\n   }\n \n-  private transpile(inputDir: string, destDir: string) {\n-    var files = this.listRecursive(inputDir);\n-    var toTranspile = [];\n-    for (var f in files) {\n-      // If it's not matching, don't translate.\n-      if (!f.match(this.includePattern)) continue;\n-      var dartVariant = f.replace(this.includePattern, '.dart');\n-      // A .dart file of the same name takes precedence over transpiled code.\n-      if (files.hasOwnProperty(dartVariant)) continue;\n-      toTranspile.push(f);\n-    }\n-    var transpiler = new ts2dart.Transpiler(\n-        {generateLibraryName: true, generateSourceMap: false, basePath: inputDir});\n-    transpiler.transpile(toTranspile, destDir);\n-  }\n+  rebuild(treeDiff: DiffResult) {\n+    let toEmit = [];\n+    let getDartVariant = (path: string) => path.replace(/((\\.js)|(\\.ts))$/i, '.dart');\n+    treeDiff.changedPaths.forEach((changedPath) => {\n+      let absolutePath = path.resolve(this.basePath, changedPath);\n+\n+      // TODO(caitp): remove when #1719 fixed\n+      if (!absolutePath.match(/((\\.js)|(\\.ts))$/i))\n+        return\n+\n+            // Ignore files which don't need to be transpiled to Dart\n+            let dartVariant = getDartVariant(absolutePath);\n+      if (fs.existsSync(dartVariant)) return;\n \n-  private listRecursive(root: string, res: Set = {}): Set {\n-    var paths = fs.readdirSync(root);\n-    paths.forEach((p) => {\n-      p = path.join(root, p);\n-      var stat = fs.statSync(p);\n-      if (stat.isDirectory()) {\n-        this.listRecursive(p, res);\n-      } else {\n-        // Collect *all* files so we can check .dart files that already exist and exclude them.\n-        res[p] = true;\n-      }\n+      // Prepare to rebuild\n+      toEmit.push(path.resolve(this.inputPath, changedPath));\n     });\n-    return res;\n+\n+    let transpiler = new ts2dart.Transpiler(this.ts2dartOpts);\n+    transpiler.transpile(toEmit, this.cachePath);","path":"tools/broccoli/broccoli-ts2dart.ts","position":77,"original_position":77,"commit_id":"11563b04f12c44f2ccc371b11f4974d0fd7dde1a","original_commit_id":"11563b04f12c44f2ccc371b11f4974d0fd7dde1a","user":{"login":"IgorMinar","id":216296,"avatar_url":"https://avatars.githubusercontent.com/u/216296?v=3","gravatar_id":"","url":"https://api.github.com/users/IgorMinar","html_url":"https://github.com/IgorMinar","followers_url":"https://api.github.com/users/IgorMinar/followers","following_url":"https://api.github.com/users/IgorMinar/following{/other_user}","gists_url":"https://api.github.com/users/IgorMinar/gists{/gist_id}","starred_url":"https://api.github.com/users/IgorMinar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IgorMinar/subscriptions","organizations_url":"https://api.github.com/users/IgorMinar/orgs","repos_url":"https://api.github.com/users/IgorMinar/repos","events_url":"https://api.github.com/users/IgorMinar/events{/privacy}","received_events_url":"https://api.github.com/users/IgorMinar/received_events","type":"User","site_admin":false},"body":"it should be just the `.dart` files and maybe sourcemaps but I think that's disabled right now.","created_at":"2015-05-08T16:27:05Z","updated_at":"2015-05-08T16:27:05Z","html_url":"https://github.com/angular/angular/pull/1733#discussion_r29953915","pull_request_url":"https://api.github.com/repos/angular/angular/pulls/1733","_links":{"self":{"href":"https://api.github.com/repos/angular/angular/pulls/comments/29953915"},"html":{"href":"https://github.com/angular/angular/pull/1733#discussion_r29953915"},"pull_request":{"href":"https://api.github.com/repos/angular/angular/pulls/1733"}}},"pull_request":{"url":"https://api.github.com/repos/angular/angular/pulls/1733","id":34944687,"html_url":"https://github.com/angular/angular/pull/1733","diff_url":"https://github.com/angular/angular/pull/1733.diff","patch_url":"https://github.com/angular/angular/pull/1733.patch","issue_url":"https://api.github.com/repos/angular/angular/issues/1733","number":1733,"state":"open","locked":false,"title":"build(brocolli): convert brocolli-ts2dart to use TreeDiffer","user":{"login":"caitp","id":2294695,"avatar_url":"https://avatars.githubusercontent.com/u/2294695?v=3","gravatar_id":"","url":"https://api.github.com/users/caitp","html_url":"https://github.com/caitp","followers_url":"https://api.github.com/users/caitp/followers","following_url":"https://api.github.com/users/caitp/following{/other_user}","gists_url":"https://api.github.com/users/caitp/gists{/gist_id}","starred_url":"https://api.github.com/users/caitp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caitp/subscriptions","organizations_url":"https://api.github.com/users/caitp/orgs","repos_url":"https://api.github.com/users/caitp/repos","events_url":"https://api.github.com/users/caitp/events{/privacy}","received_events_url":"https://api.github.com/users/caitp/received_events","type":"User","site_admin":false},"body":"Blocked on #1719\n\nCloses #1720","created_at":"2015-05-07T18:34:58Z","updated_at":"2015-05-08T16:27:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4ffc52a82cc2b0595aed1a57da93cc12062563f6","assignee":{"login":"IgorMinar","id":216296,"avatar_url":"https://avatars.githubusercontent.com/u/216296?v=3","gravatar_id":"","url":"https://api.github.com/users/IgorMinar","html_url":"https://github.com/IgorMinar","followers_url":"https://api.github.com/users/IgorMinar/followers","following_url":"https://api.github.com/users/IgorMinar/following{/other_user}","gists_url":"https://api.github.com/users/IgorMinar/gists{/gist_id}","starred_url":"https://api.github.com/users/IgorMinar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IgorMinar/subscriptions","organizations_url":"https://api.github.com/users/IgorMinar/orgs","repos_url":"https://api.github.com/users/IgorMinar/repos","events_url":"https://api.github.com/users/IgorMinar/events{/privacy}","received_events_url":"https://api.github.com/users/IgorMinar/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/angular/angular/pulls/1733/commits","review_comments_url":"https://api.github.com/repos/angular/angular/pulls/1733/comments","review_comment_url":"https://api.github.com/repos/angular/angular/pulls/comments{/number}","comments_url":"https://api.github.com/repos/angular/angular/issues/1733/comments","statuses_url":"https://api.github.com/repos/angular/angular/statuses/11563b04f12c44f2ccc371b11f4974d0fd7dde1a","head":{"label":"caitp:issue-1720","ref":"issue-1720","sha":"11563b04f12c44f2ccc371b11f4974d0fd7dde1a","user":{"login":"caitp","id":2294695,"avatar_url":"https://avatars.githubusercontent.com/u/2294695?v=3","gravatar_id":"","url":"https://api.github.com/users/caitp","html_url":"https://github.com/caitp","followers_url":"https://api.github.com/users/caitp/followers","following_url":"https://api.github.com/users/caitp/following{/other_user}","gists_url":"https://api.github.com/users/caitp/gists{/gist_id}","starred_url":"https://api.github.com/users/caitp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caitp/subscriptions","organizations_url":"https://api.github.com/users/caitp/orgs","repos_url":"https://api.github.com/users/caitp/repos","events_url":"https://api.github.com/users/caitp/events{/privacy}","received_events_url":"https://api.github.com/users/caitp/received_events","type":"User","site_admin":false},"repo":{"id":31547616,"name":"angular","full_name":"caitp/angular","owner":{"login":"caitp","id":2294695,"avatar_url":"https://avatars.githubusercontent.com/u/2294695?v=3","gravatar_id":"","url":"https://api.github.com/users/caitp","html_url":"https://github.com/caitp","followers_url":"https://api.github.com/users/caitp/followers","following_url":"https://api.github.com/users/caitp/following{/other_user}","gists_url":"https://api.github.com/users/caitp/gists{/gist_id}","starred_url":"https://api.github.com/users/caitp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caitp/subscriptions","organizations_url":"https://api.github.com/users/caitp/orgs","repos_url":"https://api.github.com/users/caitp/repos","events_url":"https://api.github.com/users/caitp/events{/privacy}","received_events_url":"https://api.github.com/users/caitp/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/caitp/angular","description":"","fork":true,"url":"https://api.github.com/repos/caitp/angular","forks_url":"https://api.github.com/repos/caitp/angular/forks","keys_url":"https://api.github.com/repos/caitp/angular/keys{/key_id}","collaborators_url":"https://api.github.com/repos/caitp/angular/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/caitp/angular/teams","hooks_url":"https://api.github.com/repos/caitp/angular/hooks","issue_events_url":"https://api.github.com/repos/caitp/angular/issues/events{/number}","events_url":"https://api.github.com/repos/caitp/angular/events","assignees_url":"https://api.github.com/repos/caitp/angular/assignees{/user}","branches_url":"https://api.github.com/repos/caitp/angular/branches{/branch}","tags_url":"https://api.github.com/repos/caitp/angular/tags","blobs_url":"https://api.github.com/repos/caitp/angular/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/caitp/angular/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/caitp/angular/git/refs{/sha}","trees_url":"https://api.github.com/repos/caitp/angular/git/trees{/sha}","statuses_url":"https://api.github.com/repos/caitp/angular/statuses/{sha}","languages_url":"https://api.github.com/repos/caitp/angular/languages","stargazers_url":"https://api.github.com/repos/caitp/angular/stargazers","contributors_url":"https://api.github.com/repos/caitp/angular/contributors","subscribers_url":"https://api.github.com/repos/caitp/angular/subscribers","subscription_url":"https://api.github.com/repos/caitp/angular/subscription","commits_url":"https://api.github.com/repos/caitp/angular/commits{/sha}","git_commits_url":"https://api.github.com/repos/caitp/angular/git/commits{/sha}","comments_url":"https://api.github.com/repos/caitp/angular/comments{/number}","issue_comment_url":"https://api.github.com/repos/caitp/angular/issues/comments{/number}","contents_url":"https://api.github.com/repos/caitp/angular/contents/{+path}","compare_url":"https://api.github.com/repos/caitp/angular/compare/{base}...{head}","merges_url":"https://api.github.com/repos/caitp/angular/merges","archive_url":"https://api.github.com/repos/caitp/angular/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/caitp/angular/downloads","issues_url":"https://api.github.com/repos/caitp/angular/issues{/number}","pulls_url":"https://api.github.com/repos/caitp/angular/pulls{/number}","milestones_url":"https://api.github.com/repos/caitp/angular/milestones{/number}","notifications_url":"https://api.github.com/repos/caitp/angular/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/caitp/angular/labels{/name}","releases_url":"https://api.github.com/repos/caitp/angular/releases{/id}","created_at":"2015-03-02T15:42:39Z","updated_at":"2015-03-02T15:42:40Z","pushed_at":"2015-05-07T22:30:37Z","git_url":"git://github.com/caitp/angular.git","ssh_url":"git@github.com:caitp/angular.git","clone_url":"https://github.com/caitp/angular.git","svn_url":"https://github.com/caitp/angular","homepage":null,"size":5615,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"angular:master","ref":"master","sha":"0e2047f9ca082e912d195338e7bae9753c908206","user":{"login":"angular","id":139426,"avatar_url":"https://avatars.githubusercontent.com/u/139426?v=3","gravatar_id":"","url":"https://api.github.com/users/angular","html_url":"https://github.com/angular","followers_url":"https://api.github.com/users/angular/followers","following_url":"https://api.github.com/users/angular/following{/other_user}","gists_url":"https://api.github.com/users/angular/gists{/gist_id}","starred_url":"https://api.github.com/users/angular/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/angular/subscriptions","organizations_url":"https://api.github.com/users/angular/orgs","repos_url":"https://api.github.com/users/angular/repos","events_url":"https://api.github.com/users/angular/events{/privacy}","received_events_url":"https://api.github.com/users/angular/received_events","type":"Organization","site_admin":false},"repo":{"id":24195339,"name":"angular","full_name":"angular/angular","owner":{"login":"angular","id":139426,"avatar_url":"https://avatars.githubusercontent.com/u/139426?v=3","gravatar_id":"","url":"https://api.github.com/users/angular","html_url":"https://github.com/angular","followers_url":"https://api.github.com/users/angular/followers","following_url":"https://api.github.com/users/angular/following{/other_user}","gists_url":"https://api.github.com/users/angular/gists{/gist_id}","starred_url":"https://api.github.com/users/angular/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/angular/subscriptions","organizations_url":"https://api.github.com/users/angular/orgs","repos_url":"https://api.github.com/users/angular/repos","events_url":"https://api.github.com/users/angular/events{/privacy}","received_events_url":"https://api.github.com/users/angular/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/angular/angular","description":"","fork":false,"url":"https://api.github.com/repos/angular/angular","forks_url":"https://api.github.com/repos/angular/angular/forks","keys_url":"https://api.github.com/repos/angular/angular/keys{/key_id}","collaborators_url":"https://api.github.com/repos/angular/angular/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/angular/angular/teams","hooks_url":"https://api.github.com/repos/angular/angular/hooks","issue_events_url":"https://api.github.com/repos/angular/angular/issues/events{/number}","events_url":"https://api.github.com/repos/angular/angular/events","assignees_url":"https://api.github.com/repos/angular/angular/assignees{/user}","branches_url":"https://api.github.com/repos/angular/angular/branches{/branch}","tags_url":"https://api.github.com/repos/angular/angular/tags","blobs_url":"https://api.github.com/repos/angular/angular/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/angular/angular/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/angular/angular/git/refs{/sha}","trees_url":"https://api.github.com/repos/angular/angular/git/trees{/sha}","statuses_url":"https://api.github.com/repos/angular/angular/statuses/{sha}","languages_url":"https://api.github.com/repos/angular/angular/languages","stargazers_url":"https://api.github.com/repos/angular/angular/stargazers","contributors_url":"https://api.github.com/repos/angular/angular/contributors","subscribers_url":"https://api.github.com/repos/angular/angular/subscribers","subscription_url":"https://api.github.com/repos/angular/angular/subscription","commits_url":"https://api.github.com/repos/angular/angular/commits{/sha}","git_commits_url":"https://api.github.com/repos/angular/angular/git/commits{/sha}","comments_url":"https://api.github.com/repos/angular/angular/comments{/number}","issue_comment_url":"https://api.github.com/repos/angular/angular/issues/comments{/number}","contents_url":"https://api.github.com/repos/angular/angular/contents/{+path}","compare_url":"https://api.github.com/repos/angular/angular/compare/{base}...{head}","merges_url":"https://api.github.com/repos/angular/angular/merges","archive_url":"https://api.github.com/repos/angular/angular/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/angular/angular/downloads","issues_url":"https://api.github.com/repos/angular/angular/issues{/number}","pulls_url":"https://api.github.com/repos/angular/angular/pulls{/number}","milestones_url":"https://api.github.com/repos/angular/angular/milestones{/number}","notifications_url":"https://api.github.com/repos/angular/angular/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/angular/angular/labels{/name}","releases_url":"https://api.github.com/repos/angular/angular/releases{/id}","created_at":"2014-09-18T16:12:01Z","updated_at":"2015-05-08T15:37:13Z","pushed_at":"2015-05-08T15:57:07Z","git_url":"git://github.com/angular/angular.git","ssh_url":"git@github.com:angular/angular.git","clone_url":"https://github.com/angular/angular.git","svn_url":"https://github.com/angular/angular","homepage":null,"size":24661,"stargazers_count":2917,"watchers_count":2917,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":750,"mirror_url":null,"open_issues_count":287,"forks":750,"open_issues":287,"watchers":2917,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/angular/angular/pulls/1733"},"html":{"href":"https://github.com/angular/angular/pull/1733"},"issue":{"href":"https://api.github.com/repos/angular/angular/issues/1733"},"comments":{"href":"https://api.github.com/repos/angular/angular/issues/1733/comments"},"review_comments":{"href":"https://api.github.com/repos/angular/angular/pulls/1733/comments"},"review_comment":{"href":"https://api.github.com/repos/angular/angular/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/angular/angular/pulls/1733/commits"},"statuses":{"href":"https://api.github.com/repos/angular/angular/statuses/11563b04f12c44f2ccc371b11f4974d0fd7dde1a"}}}}