{"action":"created","comment":{"url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/pulls/comments/212573224","pull_request_review_id":149236280,"id":212573224,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMjU3MzIyNA==","diff_hunk":"@@ -1,29 +1,35 @@\n const fs = require('fs')\n-const path = require('path')\n \n-let pathList = { files: [], dirs: [] };\n-let activeCallbackCount = 0;\n+function getTree(path, completionCallback) {\n+    let pathList = { files: [], dirs: [] };\n+    let activeCallbackCount = 0;\n \n-function getTree(path) {\n-    if (!fs.lstatSync(path).isDirectory()) {\n-        console.log(\"file: \" + path);\n-        console.log(activeCallbackCount);\n-        pathList.files.push(path);\n-        if (activeCallbackCount == 1) {\n-          console.log(pathList);\n+    (function _getTree(path) {\n+        if (!fs.lstatSync(path).isDirectory()) {\n+            pathList.files.push(path);\n+            return;\n         }\n-        return;\n-    }\n-    pathList.dirs.push(path);\n-    console.log(\"dir: \" + path);\n-    activeCallbackCount++;\n-    console.log(activeCallbackCount);\n-    fs.readdir(path, function readdirCallback(err, subpaths) {\n-        subpaths.forEach(function(element) {\n-            getTree(path + \"/\" + element)         \n+        pathList.dirs.push(path);\n+        activeCallbackCount++;\n+        fs.readdir(path, function readdirCallback(err, subpaths) {\n+            if (err) {\n+                return new Error(err)","path":"javascript/javascript-4/tree.1.js","position":16,"original_position":35,"commit_id":"d012740a2e82fc82d5f76e4f95edb104c776256c","original_commit_id":"d012740a2e82fc82d5f76e4f95edb104c776256c","user":{"login":"thoughtspile","id":5262915,"node_id":"MDQ6VXNlcjUyNjI5MTU=","avatar_url":"https://avatars1.githubusercontent.com/u/5262915?v=4","gravatar_id":"","url":"https://api.github.com/users/thoughtspile","html_url":"https://github.com/thoughtspile","followers_url":"https://api.github.com/users/thoughtspile/followers","following_url":"https://api.github.com/users/thoughtspile/following{/other_user}","gists_url":"https://api.github.com/users/thoughtspile/gists{/gist_id}","starred_url":"https://api.github.com/users/thoughtspile/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thoughtspile/subscriptions","organizations_url":"https://api.github.com/users/thoughtspile/orgs","repos_url":"https://api.github.com/users/thoughtspile/repos","events_url":"https://api.github.com/users/thoughtspile/events{/privacy}","received_events_url":"https://api.github.com/users/thoughtspile/received_events","type":"User","site_admin":false},"body":"это `return` в никуда) единственный способ передать результат из асинхронной функции с коллбеком — коллбек, и в ноде принято вызывать его с аргументами `(error, result)`. Так что тут нужно вызвать коллбек с err...","created_at":"2018-08-24T09:35:14Z","updated_at":"2018-08-24T09:36:50Z","html_url":"https://github.com/liliaretsia/retsya-lilia-otus/pull/3#discussion_r212573224","pull_request_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/pulls/3","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/pulls/comments/212573224"},"html":{"href":"https://github.com/liliaretsia/retsya-lilia-otus/pull/3#discussion_r212573224"},"pull_request":{"href":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/pulls/3","id":207626353,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA3NjI2MzUz","html_url":"https://github.com/liliaretsia/retsya-lilia-otus/pull/3","diff_url":"https://github.com/liliaretsia/retsya-lilia-otus/pull/3.diff","patch_url":"https://github.com/liliaretsia/retsya-lilia-otus/pull/3.patch","issue_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/issues/3","number":3,"state":"open","locked":false,"title":"added folders and function in tree.js which:","user":{"login":"liliaretsia","id":33622650,"node_id":"MDQ6VXNlcjMzNjIyNjUw","avatar_url":"https://avatars0.githubusercontent.com/u/33622650?v=4","gravatar_id":"","url":"https://api.github.com/users/liliaretsia","html_url":"https://github.com/liliaretsia","followers_url":"https://api.github.com/users/liliaretsia/followers","following_url":"https://api.github.com/users/liliaretsia/following{/other_user}","gists_url":"https://api.github.com/users/liliaretsia/gists{/gist_id}","starred_url":"https://api.github.com/users/liliaretsia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liliaretsia/subscriptions","organizations_url":"https://api.github.com/users/liliaretsia/orgs","repos_url":"https://api.github.com/users/liliaretsia/repos","events_url":"https://api.github.com/users/liliaretsia/events{/privacy}","received_events_url":"https://api.github.com/users/liliaretsia/received_events","type":"User","site_admin":false},"body":" - can read files, and push file names to object by type (dir or file)","created_at":"2018-08-10T14:18:25Z","updated_at":"2018-08-24T09:36:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fc1988422c109cf82d1d401547614062c7178c7f","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/pulls/3/commits","review_comments_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/pulls/3/comments","review_comment_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/pulls/comments{/number}","comments_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/issues/3/comments","statuses_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/statuses/d012740a2e82fc82d5f76e4f95edb104c776256c","head":{"label":"liliaretsia:javascript-4","ref":"javascript-4","sha":"d012740a2e82fc82d5f76e4f95edb104c776256c","user":{"login":"liliaretsia","id":33622650,"node_id":"MDQ6VXNlcjMzNjIyNjUw","avatar_url":"https://avatars0.githubusercontent.com/u/33622650?v=4","gravatar_id":"","url":"https://api.github.com/users/liliaretsia","html_url":"https://github.com/liliaretsia","followers_url":"https://api.github.com/users/liliaretsia/followers","following_url":"https://api.github.com/users/liliaretsia/following{/other_user}","gists_url":"https://api.github.com/users/liliaretsia/gists{/gist_id}","starred_url":"https://api.github.com/users/liliaretsia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liliaretsia/subscriptions","organizations_url":"https://api.github.com/users/liliaretsia/orgs","repos_url":"https://api.github.com/users/liliaretsia/repos","events_url":"https://api.github.com/users/liliaretsia/events{/privacy}","received_events_url":"https://api.github.com/users/liliaretsia/received_events","type":"User","site_admin":false},"repo":{"id":143511448,"node_id":"MDEwOlJlcG9zaXRvcnkxNDM1MTE0NDg=","name":"retsya-lilia-otus","full_name":"liliaretsia/retsya-lilia-otus","owner":{"login":"liliaretsia","id":33622650,"node_id":"MDQ6VXNlcjMzNjIyNjUw","avatar_url":"https://avatars0.githubusercontent.com/u/33622650?v=4","gravatar_id":"","url":"https://api.github.com/users/liliaretsia","html_url":"https://github.com/liliaretsia","followers_url":"https://api.github.com/users/liliaretsia/followers","following_url":"https://api.github.com/users/liliaretsia/following{/other_user}","gists_url":"https://api.github.com/users/liliaretsia/gists{/gist_id}","starred_url":"https://api.github.com/users/liliaretsia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liliaretsia/subscriptions","organizations_url":"https://api.github.com/users/liliaretsia/orgs","repos_url":"https://api.github.com/users/liliaretsia/repos","events_url":"https://api.github.com/users/liliaretsia/events{/privacy}","received_events_url":"https://api.github.com/users/liliaretsia/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/liliaretsia/retsya-lilia-otus","description":null,"fork":false,"url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus","forks_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/forks","keys_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/teams","hooks_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/hooks","issue_events_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/issues/events{/number}","events_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/events","assignees_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/assignees{/user}","branches_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/branches{/branch}","tags_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/tags","blobs_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/git/refs{/sha}","trees_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/statuses/{sha}","languages_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/languages","stargazers_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/stargazers","contributors_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/contributors","subscribers_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/subscribers","subscription_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/subscription","commits_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/commits{/sha}","git_commits_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/git/commits{/sha}","comments_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/comments{/number}","issue_comment_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/issues/comments{/number}","contents_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/contents/{+path}","compare_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/merges","archive_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/downloads","issues_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/issues{/number}","pulls_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/pulls{/number}","milestones_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/milestones{/number}","notifications_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/labels{/name}","releases_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/releases{/id}","deployments_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/deployments","created_at":"2018-08-04T08:25:57Z","updated_at":"2018-08-10T13:47:37Z","pushed_at":"2018-08-23T20:32:12Z","git_url":"git://github.com/liliaretsia/retsya-lilia-otus.git","ssh_url":"git@github.com:liliaretsia/retsya-lilia-otus.git","clone_url":"https://github.com/liliaretsia/retsya-lilia-otus.git","svn_url":"https://github.com/liliaretsia/retsya-lilia-otus","homepage":null,"size":23,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":3,"license":null,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"base":{"label":"liliaretsia:master","ref":"master","sha":"86e39e7581c469757aacde0acdac65c6b1bc06a4","user":{"login":"liliaretsia","id":33622650,"node_id":"MDQ6VXNlcjMzNjIyNjUw","avatar_url":"https://avatars0.githubusercontent.com/u/33622650?v=4","gravatar_id":"","url":"https://api.github.com/users/liliaretsia","html_url":"https://github.com/liliaretsia","followers_url":"https://api.github.com/users/liliaretsia/followers","following_url":"https://api.github.com/users/liliaretsia/following{/other_user}","gists_url":"https://api.github.com/users/liliaretsia/gists{/gist_id}","starred_url":"https://api.github.com/users/liliaretsia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liliaretsia/subscriptions","organizations_url":"https://api.github.com/users/liliaretsia/orgs","repos_url":"https://api.github.com/users/liliaretsia/repos","events_url":"https://api.github.com/users/liliaretsia/events{/privacy}","received_events_url":"https://api.github.com/users/liliaretsia/received_events","type":"User","site_admin":false},"repo":{"id":143511448,"node_id":"MDEwOlJlcG9zaXRvcnkxNDM1MTE0NDg=","name":"retsya-lilia-otus","full_name":"liliaretsia/retsya-lilia-otus","owner":{"login":"liliaretsia","id":33622650,"node_id":"MDQ6VXNlcjMzNjIyNjUw","avatar_url":"https://avatars0.githubusercontent.com/u/33622650?v=4","gravatar_id":"","url":"https://api.github.com/users/liliaretsia","html_url":"https://github.com/liliaretsia","followers_url":"https://api.github.com/users/liliaretsia/followers","following_url":"https://api.github.com/users/liliaretsia/following{/other_user}","gists_url":"https://api.github.com/users/liliaretsia/gists{/gist_id}","starred_url":"https://api.github.com/users/liliaretsia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liliaretsia/subscriptions","organizations_url":"https://api.github.com/users/liliaretsia/orgs","repos_url":"https://api.github.com/users/liliaretsia/repos","events_url":"https://api.github.com/users/liliaretsia/events{/privacy}","received_events_url":"https://api.github.com/users/liliaretsia/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/liliaretsia/retsya-lilia-otus","description":null,"fork":false,"url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus","forks_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/forks","keys_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/teams","hooks_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/hooks","issue_events_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/issues/events{/number}","events_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/events","assignees_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/assignees{/user}","branches_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/branches{/branch}","tags_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/tags","blobs_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/git/refs{/sha}","trees_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/statuses/{sha}","languages_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/languages","stargazers_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/stargazers","contributors_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/contributors","subscribers_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/subscribers","subscription_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/subscription","commits_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/commits{/sha}","git_commits_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/git/commits{/sha}","comments_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/comments{/number}","issue_comment_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/issues/comments{/number}","contents_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/contents/{+path}","compare_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/merges","archive_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/downloads","issues_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/issues{/number}","pulls_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/pulls{/number}","milestones_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/milestones{/number}","notifications_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/labels{/name}","releases_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/releases{/id}","deployments_url":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/deployments","created_at":"2018-08-04T08:25:57Z","updated_at":"2018-08-10T13:47:37Z","pushed_at":"2018-08-23T20:32:12Z","git_url":"git://github.com/liliaretsia/retsya-lilia-otus.git","ssh_url":"git@github.com:liliaretsia/retsya-lilia-otus.git","clone_url":"https://github.com/liliaretsia/retsya-lilia-otus.git","svn_url":"https://github.com/liliaretsia/retsya-lilia-otus","homepage":null,"size":23,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":3,"license":null,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/pulls/3"},"html":{"href":"https://github.com/liliaretsia/retsya-lilia-otus/pull/3"},"issue":{"href":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/issues/3"},"comments":{"href":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/liliaretsia/retsya-lilia-otus/statuses/d012740a2e82fc82d5f76e4f95edb104c776256c"}},"author_association":"OWNER"}}
{"actor":{"display_login":"thoughtspile"}}