{"action":"created","comment":{"url":"https://api.github.com/repos/eslint/eslint/pulls/comments/43584540","id":43584540,"diff_hunk":"@@ -0,0 +1,144 @@\n+/**\n+ * @fileoverview Utilities for working with globs and the filesystem.\n+ * @author Ian VanSchooten\n+ * @copyright 2015 Ian VanSchooten. All rights reserved.\n+ * See LICENSE in root directory for full license.\n+ */\n+\"use strict\";\n+\n+//------------------------------------------------------------------------------\n+// Requirements\n+//------------------------------------------------------------------------------\n+\n+var debug = require(\"debug\"),\n+    fs = require(\"fs\"),\n+    glob = require(\"glob\"),\n+    shell = require(\"shelljs\"),\n+\n+    IgnoredPaths = require(\"../ignored-paths\");\n+\n+debug = debug(\"eslint:glob-util\");\n+\n+//------------------------------------------------------------------------------\n+// Helpers\n+//------------------------------------------------------------------------------\n+\n+/**\n+ * Checks if a provided path is a directory and returns a glob string matching\n+ * all files under that directory if so, the path itself otherwise.\n+ *\n+ * Reason for this is that `glob` needs `/**` to collect all the files under a\n+ * directory where as our previous implementation without `glob` simply walked\n+ * a directory that is passed. So this is to maintain backwards compatibility.\n+ *\n+ * Also makes sure all path separators are POSIX style for `glob` compatibility.\n+ *\n+ * @param {string[]} [extensions] An array of accepted extensions\n+ * @returns {Function} A function that takes a pathname and returns a glob that\n+ *                     matches all files with the provided extensions if\n+ *                     pathname is a directory.\n+ */\n+function processPath(extensions) {\n+    var suffix = \"/**\";\n+\n+    if (extensions) {\n+        if (extensions.length === 1) {\n+            suffix += \"/*.\" + extensions[0];\n+        } else {\n+            suffix += \"/*.{\" + extensions.join(\",\") + \"}\";\n+        }\n+    }\n+\n+    /**\n+     * A function that converts a directory name to a glob pattern\n+     *\n+     * @param {string} pathname The directory path to be modified\n+     * @returns {string} The glob path or the file path itself\n+     * @private\n+     */\n+    return function(pathname) {\n+        var newPath = pathname;\n+\n+        if (shell.test(\"-d\", pathname)) {\n+            newPath = pathname.replace(/[\\/\\\\]$/, \"\") + suffix;\n+        }\n+\n+        return newPath.replace(/\\\\/g, \"/\").replace(/^\\.\\//, \"\");\n+    };\n+}\n+\n+//------------------------------------------------------------------------------\n+// Public Interface\n+//------------------------------------------------------------------------------\n+","path":"lib/util/glob-util.js","position":73,"original_position":73,"commit_id":"9804406660cc32f8d609f797db3c737644c83c19","original_commit_id":"9804406660cc32f8d609f797db3c737644c83c19","user":{"login":"nzakas","id":38546,"avatar_url":"https://avatars.githubusercontent.com/u/38546?v=3","gravatar_id":"","url":"https://api.github.com/users/nzakas","html_url":"https://github.com/nzakas","followers_url":"https://api.github.com/users/nzakas/followers","following_url":"https://api.github.com/users/nzakas/following{/other_user}","gists_url":"https://api.github.com/users/nzakas/gists{/gist_id}","starred_url":"https://api.github.com/users/nzakas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nzakas/subscriptions","organizations_url":"https://api.github.com/users/nzakas/orgs","repos_url":"https://api.github.com/users/nzakas/repos","events_url":"https://api.github.com/users/nzakas/events{/privacy}","received_events_url":"https://api.github.com/users/nzakas/received_events","type":"User","site_admin":false},"body":"Please use the form\r\n\r\n```js\r\nmodule.exports = {\r\n\r\n};\r\n```\r\n\r\nThis is what we use throughout the code base. ","created_at":"2015-11-01T16:48:47Z","updated_at":"2015-11-01T16:48:47Z","html_url":"https://github.com/eslint/eslint/pull/4306#discussion_r43584540","pull_request_url":"https://api.github.com/repos/eslint/eslint/pulls/4306","_links":{"self":{"href":"https://api.github.com/repos/eslint/eslint/pulls/comments/43584540"},"html":{"href":"https://github.com/eslint/eslint/pull/4306#discussion_r43584540"},"pull_request":{"href":"https://api.github.com/repos/eslint/eslint/pulls/4306"}}},"pull_request":{"url":"https://api.github.com/repos/eslint/eslint/pulls/4306","id":49342488,"html_url":"https://github.com/eslint/eslint/pull/4306","diff_url":"https://github.com/eslint/eslint/pull/4306.diff","patch_url":"https://github.com/eslint/eslint/pull/4306.patch","issue_url":"https://api.github.com/repos/eslint/eslint/issues/4306","number":4306,"state":"open","locked":false,"title":"Update: Extract glob and filesystem logic from cli-engine (fixes #4305)","user":{"login":"IanVS","id":4616705,"avatar_url":"https://avatars.githubusercontent.com/u/4616705?v=3","gravatar_id":"","url":"https://api.github.com/users/IanVS","html_url":"https://github.com/IanVS","followers_url":"https://api.github.com/users/IanVS/followers","following_url":"https://api.github.com/users/IanVS/following{/other_user}","gists_url":"https://api.github.com/users/IanVS/gists{/gist_id}","starred_url":"https://api.github.com/users/IanVS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IanVS/subscriptions","organizations_url":"https://api.github.com/users/IanVS/orgs","repos_url":"https://api.github.com/users/IanVS/repos","events_url":"https://api.github.com/users/IanVS/events{/privacy}","received_events_url":"https://api.github.com/users/IanVS/received_events","type":"User","site_admin":false},"body":"This will also make some of the tricky glob functions more testable.","created_at":"2015-10-31T05:36:22Z","updated_at":"2015-11-01T16:48:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4768c09ca099bc8a83e9421fbb2f168ef8daca0f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/eslint/eslint/pulls/4306/commits","review_comments_url":"https://api.github.com/repos/eslint/eslint/pulls/4306/comments","review_comment_url":"https://api.github.com/repos/eslint/eslint/pulls/comments{/number}","comments_url":"https://api.github.com/repos/eslint/eslint/issues/4306/comments","statuses_url":"https://api.github.com/repos/eslint/eslint/statuses/9804406660cc32f8d609f797db3c737644c83c19","head":{"label":"eslint:issue4305","ref":"issue4305","sha":"9804406660cc32f8d609f797db3c737644c83c19","user":{"login":"eslint","id":6019716,"avatar_url":"https://avatars.githubusercontent.com/u/6019716?v=3","gravatar_id":"","url":"https://api.github.com/users/eslint","html_url":"https://github.com/eslint","followers_url":"https://api.github.com/users/eslint/followers","following_url":"https://api.github.com/users/eslint/following{/other_user}","gists_url":"https://api.github.com/users/eslint/gists{/gist_id}","starred_url":"https://api.github.com/users/eslint/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eslint/subscriptions","organizations_url":"https://api.github.com/users/eslint/orgs","repos_url":"https://api.github.com/users/eslint/repos","events_url":"https://api.github.com/users/eslint/events{/privacy}","received_events_url":"https://api.github.com/users/eslint/received_events","type":"Organization","site_admin":false},"repo":{"id":11061773,"name":"eslint","full_name":"eslint/eslint","owner":{"login":"eslint","id":6019716,"avatar_url":"https://avatars.githubusercontent.com/u/6019716?v=3","gravatar_id":"","url":"https://api.github.com/users/eslint","html_url":"https://github.com/eslint","followers_url":"https://api.github.com/users/eslint/followers","following_url":"https://api.github.com/users/eslint/following{/other_user}","gists_url":"https://api.github.com/users/eslint/gists{/gist_id}","starred_url":"https://api.github.com/users/eslint/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eslint/subscriptions","organizations_url":"https://api.github.com/users/eslint/orgs","repos_url":"https://api.github.com/users/eslint/repos","events_url":"https://api.github.com/users/eslint/events{/privacy}","received_events_url":"https://api.github.com/users/eslint/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/eslint/eslint","description":"A fully pluggable tool for identifying and reporting on patterns in JavaScript.","fork":false,"url":"https://api.github.com/repos/eslint/eslint","forks_url":"https://api.github.com/repos/eslint/eslint/forks","keys_url":"https://api.github.com/repos/eslint/eslint/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eslint/eslint/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eslint/eslint/teams","hooks_url":"https://api.github.com/repos/eslint/eslint/hooks","issue_events_url":"https://api.github.com/repos/eslint/eslint/issues/events{/number}","events_url":"https://api.github.com/repos/eslint/eslint/events","assignees_url":"https://api.github.com/repos/eslint/eslint/assignees{/user}","branches_url":"https://api.github.com/repos/eslint/eslint/branches{/branch}","tags_url":"https://api.github.com/repos/eslint/eslint/tags","blobs_url":"https://api.github.com/repos/eslint/eslint/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eslint/eslint/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eslint/eslint/git/refs{/sha}","trees_url":"https://api.github.com/repos/eslint/eslint/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eslint/eslint/statuses/{sha}","languages_url":"https://api.github.com/repos/eslint/eslint/languages","stargazers_url":"https://api.github.com/repos/eslint/eslint/stargazers","contributors_url":"https://api.github.com/repos/eslint/eslint/contributors","subscribers_url":"https://api.github.com/repos/eslint/eslint/subscribers","subscription_url":"https://api.github.com/repos/eslint/eslint/subscription","commits_url":"https://api.github.com/repos/eslint/eslint/commits{/sha}","git_commits_url":"https://api.github.com/repos/eslint/eslint/git/commits{/sha}","comments_url":"https://api.github.com/repos/eslint/eslint/comments{/number}","issue_comment_url":"https://api.github.com/repos/eslint/eslint/issues/comments{/number}","contents_url":"https://api.github.com/repos/eslint/eslint/contents/{+path}","compare_url":"https://api.github.com/repos/eslint/eslint/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eslint/eslint/merges","archive_url":"https://api.github.com/repos/eslint/eslint/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eslint/eslint/downloads","issues_url":"https://api.github.com/repos/eslint/eslint/issues{/number}","pulls_url":"https://api.github.com/repos/eslint/eslint/pulls{/number}","milestones_url":"https://api.github.com/repos/eslint/eslint/milestones{/number}","notifications_url":"https://api.github.com/repos/eslint/eslint/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eslint/eslint/labels{/name}","releases_url":"https://api.github.com/repos/eslint/eslint/releases{/id}","created_at":"2013-06-29T23:59:48Z","updated_at":"2015-11-01T16:18:26Z","pushed_at":"2015-11-01T16:38:20Z","git_url":"git://github.com/eslint/eslint.git","ssh_url":"git@github.com:eslint/eslint.git","clone_url":"https://github.com/eslint/eslint.git","svn_url":"https://github.com/eslint/eslint","homepage":"http://eslint.org","size":24685,"stargazers_count":3267,"watchers_count":3267,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":609,"mirror_url":null,"open_issues_count":186,"forks":609,"open_issues":186,"watchers":3267,"default_branch":"master"}},"base":{"label":"eslint:master","ref":"master","sha":"dfcb0b09d6d83c9afb311976b8420b753984dfb6","user":{"login":"eslint","id":6019716,"avatar_url":"https://avatars.githubusercontent.com/u/6019716?v=3","gravatar_id":"","url":"https://api.github.com/users/eslint","html_url":"https://github.com/eslint","followers_url":"https://api.github.com/users/eslint/followers","following_url":"https://api.github.com/users/eslint/following{/other_user}","gists_url":"https://api.github.com/users/eslint/gists{/gist_id}","starred_url":"https://api.github.com/users/eslint/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eslint/subscriptions","organizations_url":"https://api.github.com/users/eslint/orgs","repos_url":"https://api.github.com/users/eslint/repos","events_url":"https://api.github.com/users/eslint/events{/privacy}","received_events_url":"https://api.github.com/users/eslint/received_events","type":"Organization","site_admin":false},"repo":{"id":11061773,"name":"eslint","full_name":"eslint/eslint","owner":{"login":"eslint","id":6019716,"avatar_url":"https://avatars.githubusercontent.com/u/6019716?v=3","gravatar_id":"","url":"https://api.github.com/users/eslint","html_url":"https://github.com/eslint","followers_url":"https://api.github.com/users/eslint/followers","following_url":"https://api.github.com/users/eslint/following{/other_user}","gists_url":"https://api.github.com/users/eslint/gists{/gist_id}","starred_url":"https://api.github.com/users/eslint/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eslint/subscriptions","organizations_url":"https://api.github.com/users/eslint/orgs","repos_url":"https://api.github.com/users/eslint/repos","events_url":"https://api.github.com/users/eslint/events{/privacy}","received_events_url":"https://api.github.com/users/eslint/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/eslint/eslint","description":"A fully pluggable tool for identifying and reporting on patterns in JavaScript.","fork":false,"url":"https://api.github.com/repos/eslint/eslint","forks_url":"https://api.github.com/repos/eslint/eslint/forks","keys_url":"https://api.github.com/repos/eslint/eslint/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eslint/eslint/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eslint/eslint/teams","hooks_url":"https://api.github.com/repos/eslint/eslint/hooks","issue_events_url":"https://api.github.com/repos/eslint/eslint/issues/events{/number}","events_url":"https://api.github.com/repos/eslint/eslint/events","assignees_url":"https://api.github.com/repos/eslint/eslint/assignees{/user}","branches_url":"https://api.github.com/repos/eslint/eslint/branches{/branch}","tags_url":"https://api.github.com/repos/eslint/eslint/tags","blobs_url":"https://api.github.com/repos/eslint/eslint/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eslint/eslint/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eslint/eslint/git/refs{/sha}","trees_url":"https://api.github.com/repos/eslint/eslint/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eslint/eslint/statuses/{sha}","languages_url":"https://api.github.com/repos/eslint/eslint/languages","stargazers_url":"https://api.github.com/repos/eslint/eslint/stargazers","contributors_url":"https://api.github.com/repos/eslint/eslint/contributors","subscribers_url":"https://api.github.com/repos/eslint/eslint/subscribers","subscription_url":"https://api.github.com/repos/eslint/eslint/subscription","commits_url":"https://api.github.com/repos/eslint/eslint/commits{/sha}","git_commits_url":"https://api.github.com/repos/eslint/eslint/git/commits{/sha}","comments_url":"https://api.github.com/repos/eslint/eslint/comments{/number}","issue_comment_url":"https://api.github.com/repos/eslint/eslint/issues/comments{/number}","contents_url":"https://api.github.com/repos/eslint/eslint/contents/{+path}","compare_url":"https://api.github.com/repos/eslint/eslint/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eslint/eslint/merges","archive_url":"https://api.github.com/repos/eslint/eslint/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eslint/eslint/downloads","issues_url":"https://api.github.com/repos/eslint/eslint/issues{/number}","pulls_url":"https://api.github.com/repos/eslint/eslint/pulls{/number}","milestones_url":"https://api.github.com/repos/eslint/eslint/milestones{/number}","notifications_url":"https://api.github.com/repos/eslint/eslint/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eslint/eslint/labels{/name}","releases_url":"https://api.github.com/repos/eslint/eslint/releases{/id}","created_at":"2013-06-29T23:59:48Z","updated_at":"2015-11-01T16:18:26Z","pushed_at":"2015-11-01T16:38:20Z","git_url":"git://github.com/eslint/eslint.git","ssh_url":"git@github.com:eslint/eslint.git","clone_url":"https://github.com/eslint/eslint.git","svn_url":"https://github.com/eslint/eslint","homepage":"http://eslint.org","size":24685,"stargazers_count":3267,"watchers_count":3267,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":609,"mirror_url":null,"open_issues_count":186,"forks":609,"open_issues":186,"watchers":3267,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/eslint/eslint/pulls/4306"},"html":{"href":"https://github.com/eslint/eslint/pull/4306"},"issue":{"href":"https://api.github.com/repos/eslint/eslint/issues/4306"},"comments":{"href":"https://api.github.com/repos/eslint/eslint/issues/4306/comments"},"review_comments":{"href":"https://api.github.com/repos/eslint/eslint/pulls/4306/comments"},"review_comment":{"href":"https://api.github.com/repos/eslint/eslint/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/eslint/eslint/pulls/4306/commits"},"statuses":{"href":"https://api.github.com/repos/eslint/eslint/statuses/9804406660cc32f8d609f797db3c737644c83c19"}}}}