{"action":"created","comment":{"url":"https://api.github.com/repos/facebook/jscodeshift/pulls/comments/93706117","pull_request_review_id":14238974,"id":93706117,"diff_hunk":"@@ -172,16 +161,63 @@ function run(transformFile, paths, options) {\n         reject(e.message);\n       });\n     });\n-  } else if (!fs.existsSync(transformFile)) {\n-    process.stderr.write(\n-      colors.white.bgRed('ERROR') + ' Transform file ' + transformFile + ' does not exist \\n'\n-    );\n-    return;\n-  } else {\n-    return transform(transformFile);\n+  } else if (fs.existsSync(transform)) {\n+    let stats = fs.lstatSync(transform);\n+\n+    if (stats && stats.isFile(transform)) {\n+      // handle file\n+      return transform;\n+    } else if (stats && stats.isDirectory(transform)) {\n+      let directory = path.join(transform, 'transforms');\n+      let file = path.join(transform, 'transformjs');\n+\n+      // handle directory\n+      if (fs.existsSync(directory) && fs.lstatSync(directory).isDirectory()) {\n+        return fs.readdirSync(directory);\n+      } else if (fs.existsSync(file) && fs.lstatSync(file).isFile()) {\n+        return file;\n+      } else {\n+        return fs.readdirSync(transform);\n+      }\n+    } else {\n+      // handle other fs objects\n+      return transform;\n+    }\n+  }\n+\n+  try {\n+    // handle npm package as directory\n+    return getTransform(require.resolve(transform));\n+  } catch (e) {\n+    // error\n+    return Promise.reject('Transform ' + transform + ' does not exist');\n   }\n+}\n+\n+function run(transforms, paths, options) {\n+  const cpus = options.cpus ? Math.min(availableCpus, options.cpus) : availableCpus;\n+  const extensions =\n+    options.extensions && options.extensions.split(',').map(ext => '.' + ext);\n+  const fileCounters = {error: 0, ok: 0, nochange: 0, skip: 0};\n+  const statsCounter = {};\n+  const startTime = process.hrtime();\n \n-  function transform(transformFile) {\n+  ignores.add(options.ignorePattern);\n+  ignores.addFromFile(options.ignoreConfig);\n+\n+  transforms = Array.isArray(transforms) ? transforms : [transformfiles]","path":"src/Runner.js","position":93,"original_position":93,"commit_id":"797066038c24fb912535da367ca6dc0e4d4c11c3","original_commit_id":"797066038c24fb912535da367ca6dc0e4d4c11c3","user":{"login":"fkling","id":179026,"avatar_url":"https://avatars.githubusercontent.com/u/179026?v=3","gravatar_id":"","url":"https://api.github.com/users/fkling","html_url":"https://github.com/fkling","followers_url":"https://api.github.com/users/fkling/followers","following_url":"https://api.github.com/users/fkling/following{/other_user}","gists_url":"https://api.github.com/users/fkling/gists{/gist_id}","starred_url":"https://api.github.com/users/fkling/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fkling/subscriptions","organizations_url":"https://api.github.com/users/fkling/orgs","repos_url":"https://api.github.com/users/fkling/repos","events_url":"https://api.github.com/users/fkling/events{/privacy}","received_events_url":"https://api.github.com/users/fkling/received_events","type":"User","site_admin":false},"body":"I believe this should be `[transforms]` here?","created_at":"2016-12-22T22:24:01Z","updated_at":"2016-12-22T22:32:01Z","html_url":"https://github.com/facebook/jscodeshift/pull/171#discussion_r93706117","pull_request_url":"https://api.github.com/repos/facebook/jscodeshift/pulls/171","_links":{"self":{"href":"https://api.github.com/repos/facebook/jscodeshift/pulls/comments/93706117"},"html":{"href":"https://github.com/facebook/jscodeshift/pull/171#discussion_r93706117"},"pull_request":{"href":"https://api.github.com/repos/facebook/jscodeshift/pulls/171"}}},"pull_request":{"url":"https://api.github.com/repos/facebook/jscodeshift/pulls/171","id":97251233,"html_url":"https://github.com/facebook/jscodeshift/pull/171","diff_url":"https://github.com/facebook/jscodeshift/pull/171.diff","patch_url":"https://github.com/facebook/jscodeshift/pull/171.patch","issue_url":"https://api.github.com/repos/facebook/jscodeshift/issues/171","number":171,"state":"open","locked":false,"title":"Multiple transform support for Workers","user":{"login":"nickmccurdy","id":927220,"avatar_url":"https://avatars.githubusercontent.com/u/927220?v=3","gravatar_id":"","url":"https://api.github.com/users/nickmccurdy","html_url":"https://github.com/nickmccurdy","followers_url":"https://api.github.com/users/nickmccurdy/followers","following_url":"https://api.github.com/users/nickmccurdy/following{/other_user}","gists_url":"https://api.github.com/users/nickmccurdy/gists{/gist_id}","starred_url":"https://api.github.com/users/nickmccurdy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nickmccurdy/subscriptions","organizations_url":"https://api.github.com/users/nickmccurdy/orgs","repos_url":"https://api.github.com/users/nickmccurdy/repos","events_url":"https://api.github.com/users/nickmccurdy/events{/privacy}","received_events_url":"https://api.github.com/users/nickmccurdy/received_events","type":"User","site_admin":false},"body":"Fixes #126 and #148.\r\n- [x] Allow the `--transform` flag to be repeated to run multiple transforms in order.\r\n- [x] Change the Runner's API to support multiple transforms. ~~I wanted to do this at first, but I wasn't sure if it would make sense to add a potentially breaking change to this PR.~~\r\n- [x] Support passing a directory or npm package instead of specific files.\r\n- [ ] Keep the AST in memory between each transform, instead of writing and reading to disk between transforms.\r\n- [ ] Test all new use cases.","created_at":"2016-12-09T04:55:01Z","updated_at":"2016-12-22T22:32:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"78c8e2fe182645b9ccde71b736f3979f15e8c84b","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/facebook/jscodeshift/pulls/171/commits","review_comments_url":"https://api.github.com/repos/facebook/jscodeshift/pulls/171/comments","review_comment_url":"https://api.github.com/repos/facebook/jscodeshift/pulls/comments{/number}","comments_url":"https://api.github.com/repos/facebook/jscodeshift/issues/171/comments","statuses_url":"https://api.github.com/repos/facebook/jscodeshift/statuses/797066038c24fb912535da367ca6dc0e4d4c11c3","head":{"label":"nickmccurdy:multiple-transforms","ref":"multiple-transforms","sha":"797066038c24fb912535da367ca6dc0e4d4c11c3","user":{"login":"nickmccurdy","id":927220,"avatar_url":"https://avatars.githubusercontent.com/u/927220?v=3","gravatar_id":"","url":"https://api.github.com/users/nickmccurdy","html_url":"https://github.com/nickmccurdy","followers_url":"https://api.github.com/users/nickmccurdy/followers","following_url":"https://api.github.com/users/nickmccurdy/following{/other_user}","gists_url":"https://api.github.com/users/nickmccurdy/gists{/gist_id}","starred_url":"https://api.github.com/users/nickmccurdy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nickmccurdy/subscriptions","organizations_url":"https://api.github.com/users/nickmccurdy/orgs","repos_url":"https://api.github.com/users/nickmccurdy/repos","events_url":"https://api.github.com/users/nickmccurdy/events{/privacy}","received_events_url":"https://api.github.com/users/nickmccurdy/received_events","type":"User","site_admin":false},"repo":{"id":75995643,"name":"jscodeshift","full_name":"nickmccurdy/jscodeshift","owner":{"login":"nickmccurdy","id":927220,"avatar_url":"https://avatars.githubusercontent.com/u/927220?v=3","gravatar_id":"","url":"https://api.github.com/users/nickmccurdy","html_url":"https://github.com/nickmccurdy","followers_url":"https://api.github.com/users/nickmccurdy/followers","following_url":"https://api.github.com/users/nickmccurdy/following{/other_user}","gists_url":"https://api.github.com/users/nickmccurdy/gists{/gist_id}","starred_url":"https://api.github.com/users/nickmccurdy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nickmccurdy/subscriptions","organizations_url":"https://api.github.com/users/nickmccurdy/orgs","repos_url":"https://api.github.com/users/nickmccurdy/repos","events_url":"https://api.github.com/users/nickmccurdy/events{/privacy}","received_events_url":"https://api.github.com/users/nickmccurdy/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nickmccurdy/jscodeshift","description":"A JavaScript codemod toolkit.","fork":true,"url":"https://api.github.com/repos/nickmccurdy/jscodeshift","forks_url":"https://api.github.com/repos/nickmccurdy/jscodeshift/forks","keys_url":"https://api.github.com/repos/nickmccurdy/jscodeshift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nickmccurdy/jscodeshift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nickmccurdy/jscodeshift/teams","hooks_url":"https://api.github.com/repos/nickmccurdy/jscodeshift/hooks","issue_events_url":"https://api.github.com/repos/nickmccurdy/jscodeshift/issues/events{/number}","events_url":"https://api.github.com/repos/nickmccurdy/jscodeshift/events","assignees_url":"https://api.github.com/repos/nickmccurdy/jscodeshift/assignees{/user}","branches_url":"https://api.github.com/repos/nickmccurdy/jscodeshift/branches{/branch}","tags_url":"https://api.github.com/repos/nickmccurdy/jscodeshift/tags","blobs_url":"https://api.github.com/repos/nickmccurdy/jscodeshift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nickmccurdy/jscodeshift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nickmccurdy/jscodeshift/git/refs{/sha}","trees_url":"https://api.github.com/repos/nickmccurdy/jscodeshift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nickmccurdy/jscodeshift/statuses/{sha}","languages_url":"https://api.github.com/repos/nickmccurdy/jscodeshift/languages","stargazers_url":"https://api.github.com/repos/nickmccurdy/jscodeshift/stargazers","contributors_url":"https://api.github.com/repos/nickmccurdy/jscodeshift/contributors","subscribers_url":"https://api.github.com/repos/nickmccurdy/jscodeshift/subscribers","subscription_url":"https://api.github.com/repos/nickmccurdy/jscodeshift/subscription","commits_url":"https://api.github.com/repos/nickmccurdy/jscodeshift/commits{/sha}","git_commits_url":"https://api.github.com/repos/nickmccurdy/jscodeshift/git/commits{/sha}","comments_url":"https://api.github.com/repos/nickmccurdy/jscodeshift/comments{/number}","issue_comment_url":"https://api.github.com/repos/nickmccurdy/jscodeshift/issues/comments{/number}","contents_url":"https://api.github.com/repos/nickmccurdy/jscodeshift/contents/{+path}","compare_url":"https://api.github.com/repos/nickmccurdy/jscodeshift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nickmccurdy/jscodeshift/merges","archive_url":"https://api.github.com/repos/nickmccurdy/jscodeshift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nickmccurdy/jscodeshift/downloads","issues_url":"https://api.github.com/repos/nickmccurdy/jscodeshift/issues{/number}","pulls_url":"https://api.github.com/repos/nickmccurdy/jscodeshift/pulls{/number}","milestones_url":"https://api.github.com/repos/nickmccurdy/jscodeshift/milestones{/number}","notifications_url":"https://api.github.com/repos/nickmccurdy/jscodeshift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nickmccurdy/jscodeshift/labels{/name}","releases_url":"https://api.github.com/repos/nickmccurdy/jscodeshift/releases{/id}","deployments_url":"https://api.github.com/repos/nickmccurdy/jscodeshift/deployments","created_at":"2016-12-09T02:53:07Z","updated_at":"2016-12-09T02:53:08Z","pushed_at":"2016-12-21T04:28:18Z","git_url":"git://github.com/nickmccurdy/jscodeshift.git","ssh_url":"git@github.com:nickmccurdy/jscodeshift.git","clone_url":"https://github.com/nickmccurdy/jscodeshift.git","svn_url":"https://github.com/nickmccurdy/jscodeshift","homepage":"","size":627,"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":"facebook:master","ref":"master","sha":"eb9a30ba2e39d6324a9af698862677ce182e848a","user":{"login":"facebook","id":69631,"avatar_url":"https://avatars.githubusercontent.com/u/69631?v=3","gravatar_id":"","url":"https://api.github.com/users/facebook","html_url":"https://github.com/facebook","followers_url":"https://api.github.com/users/facebook/followers","following_url":"https://api.github.com/users/facebook/following{/other_user}","gists_url":"https://api.github.com/users/facebook/gists{/gist_id}","starred_url":"https://api.github.com/users/facebook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebook/subscriptions","organizations_url":"https://api.github.com/users/facebook/orgs","repos_url":"https://api.github.com/users/facebook/repos","events_url":"https://api.github.com/users/facebook/events{/privacy}","received_events_url":"https://api.github.com/users/facebook/received_events","type":"Organization","site_admin":false},"repo":{"id":31795422,"name":"jscodeshift","full_name":"facebook/jscodeshift","owner":{"login":"facebook","id":69631,"avatar_url":"https://avatars.githubusercontent.com/u/69631?v=3","gravatar_id":"","url":"https://api.github.com/users/facebook","html_url":"https://github.com/facebook","followers_url":"https://api.github.com/users/facebook/followers","following_url":"https://api.github.com/users/facebook/following{/other_user}","gists_url":"https://api.github.com/users/facebook/gists{/gist_id}","starred_url":"https://api.github.com/users/facebook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebook/subscriptions","organizations_url":"https://api.github.com/users/facebook/orgs","repos_url":"https://api.github.com/users/facebook/repos","events_url":"https://api.github.com/users/facebook/events{/privacy}","received_events_url":"https://api.github.com/users/facebook/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/facebook/jscodeshift","description":"A JavaScript codemod toolkit.","fork":false,"url":"https://api.github.com/repos/facebook/jscodeshift","forks_url":"https://api.github.com/repos/facebook/jscodeshift/forks","keys_url":"https://api.github.com/repos/facebook/jscodeshift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/facebook/jscodeshift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/facebook/jscodeshift/teams","hooks_url":"https://api.github.com/repos/facebook/jscodeshift/hooks","issue_events_url":"https://api.github.com/repos/facebook/jscodeshift/issues/events{/number}","events_url":"https://api.github.com/repos/facebook/jscodeshift/events","assignees_url":"https://api.github.com/repos/facebook/jscodeshift/assignees{/user}","branches_url":"https://api.github.com/repos/facebook/jscodeshift/branches{/branch}","tags_url":"https://api.github.com/repos/facebook/jscodeshift/tags","blobs_url":"https://api.github.com/repos/facebook/jscodeshift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/facebook/jscodeshift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/facebook/jscodeshift/git/refs{/sha}","trees_url":"https://api.github.com/repos/facebook/jscodeshift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/facebook/jscodeshift/statuses/{sha}","languages_url":"https://api.github.com/repos/facebook/jscodeshift/languages","stargazers_url":"https://api.github.com/repos/facebook/jscodeshift/stargazers","contributors_url":"https://api.github.com/repos/facebook/jscodeshift/contributors","subscribers_url":"https://api.github.com/repos/facebook/jscodeshift/subscribers","subscription_url":"https://api.github.com/repos/facebook/jscodeshift/subscription","commits_url":"https://api.github.com/repos/facebook/jscodeshift/commits{/sha}","git_commits_url":"https://api.github.com/repos/facebook/jscodeshift/git/commits{/sha}","comments_url":"https://api.github.com/repos/facebook/jscodeshift/comments{/number}","issue_comment_url":"https://api.github.com/repos/facebook/jscodeshift/issues/comments{/number}","contents_url":"https://api.github.com/repos/facebook/jscodeshift/contents/{+path}","compare_url":"https://api.github.com/repos/facebook/jscodeshift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/facebook/jscodeshift/merges","archive_url":"https://api.github.com/repos/facebook/jscodeshift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/facebook/jscodeshift/downloads","issues_url":"https://api.github.com/repos/facebook/jscodeshift/issues{/number}","pulls_url":"https://api.github.com/repos/facebook/jscodeshift/pulls{/number}","milestones_url":"https://api.github.com/repos/facebook/jscodeshift/milestones{/number}","notifications_url":"https://api.github.com/repos/facebook/jscodeshift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/facebook/jscodeshift/labels{/name}","releases_url":"https://api.github.com/repos/facebook/jscodeshift/releases{/id}","deployments_url":"https://api.github.com/repos/facebook/jscodeshift/deployments","created_at":"2015-03-07T00:32:16Z","updated_at":"2016-12-22T20:34:56Z","pushed_at":"2016-12-21T04:28:20Z","git_url":"git://github.com/facebook/jscodeshift.git","ssh_url":"git@github.com:facebook/jscodeshift.git","clone_url":"https://github.com/facebook/jscodeshift.git","svn_url":"https://github.com/facebook/jscodeshift","homepage":"","size":712,"stargazers_count":1631,"watchers_count":1631,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":89,"mirror_url":null,"open_issues_count":33,"forks":89,"open_issues":33,"watchers":1631,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/facebook/jscodeshift/pulls/171"},"html":{"href":"https://github.com/facebook/jscodeshift/pull/171"},"issue":{"href":"https://api.github.com/repos/facebook/jscodeshift/issues/171"},"comments":{"href":"https://api.github.com/repos/facebook/jscodeshift/issues/171/comments"},"review_comments":{"href":"https://api.github.com/repos/facebook/jscodeshift/pulls/171/comments"},"review_comment":{"href":"https://api.github.com/repos/facebook/jscodeshift/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/facebook/jscodeshift/pulls/171/commits"},"statuses":{"href":"https://api.github.com/repos/facebook/jscodeshift/statuses/797066038c24fb912535da367ca6dc0e4d4c11c3"}}}}
{"actor":{"display_login":"fkling"}}