{"action":"created","comment":{"url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/pulls/comments/170001819","pull_request_review_id":98616207,"id":170001819,"diff_hunk":"@@ -0,0 +1,111 @@\n+const fs = require(`fs`);\n+const readline = require(`readline`);\n+const generateFormattedData = require(`./generate-data.js`);\n+const createFile = require(`./create-file.js`);\n+\n+const {promisify} = require(`util`);\n+const open = promisify(fs.open);\n+\n+const rl = readline.createInterface({input: process.stdin, output: process.stdout});\n+\n+const logMessage = (message) => {\n+  console.log(message.green);\n+};\n+\n+const logError = (error) => {\n+  console.error(error.red);\n+};\n+\n+const createFileWith = (itemsCount, filePath) => {\n+  const options = {\n+    filePath,\n+    data: generateFormattedData(itemsCount),\n+  };\n+\n+  return createFile(options);\n+};\n+\n+const askGenerateData = () =>\n+  new Promise((resolve, reject) => {\n+    const handleAnswer = (answer) => {\n+      if (answer.trim() === `y`) {\n+        resolve();\n+      } else {\n+        logMessage(`Bye-bye!`);\n+        reject();\n+      }\n+    };\n+\n+    rl.question(`Generate data file? (type 'y' for yes): `, handleAnswer);\n+  });\n+\n+const askItemCount = () =>\n+  new Promise((resolve, reject) => {\n+    const handleAnswer = (answer) => {\n+      const itemsCount = parseInt(answer, 10);\n+\n+      if (!Number.isNaN(itemsCount)) {\n+        resolve(itemsCount);\n+      } else {\n+        logError(`Number, please.`);\n+        reject();\n+      }\n+    };\n+\n+    rl.question(`Number of entities to generate: `, handleAnswer);\n+  });\n+\n+const askFilePath = () =>\n+  new Promise((resolve) => {\n+    const handleAnswer = (fileName) => {\n+      resolve(`${process.cwd()}/${fileName}.json`);\n+    };\n+\n+    rl.question(`Enter filename w/o extension (e.g. data): `, handleAnswer);\n+  });\n+\n+const checkExist = (filePath) =>\n+  open(filePath, `r`)\n+      .then(() => true)\n+      .catch(() => false);\n+\n+const askRewrite = () =>\n+  new Promise((resolve, reject) => {\n+    const handleAnswer = (answer) => {\n+      if (answer.trim() === `y`) {\n+        resolve(true);\n+      } else {\n+        logMessage(`File left intact. Bye-bye!`);\n+        reject(false);\n+      }\n+    };\n+\n+    rl.question(`Rewrite file? (type 'y' for yes): `, handleAnswer);\n+  });\n+\n+module.exports = {\n+  name: `default`,\n+  description: `Generates data file`,\n+  async execute() {\n+    try {\n+      await askGenerateData();\n+\n+      const itemsCount = await askItemCount();\n+      const filePath = await askFilePath();\n+      const isFileExists = await checkExist(filePath);\n+\n+      if (isFileExists && !await askRewrite()) {\n+        process.exit(0);\n+      }\n+      await createFileWith(itemsCount, filePath);\n+\n+      const message = isFileExists ?\n+        `Task complete. File was overwritten.` : `Task complete. File was created.`;\n+      logMessage(message);\n+\n+      process.exit(0);","path":"src/default.js","position":106,"original_position":106,"commit_id":"98e7a2a31cc524921d66d59b73fd355f7df76d24","original_commit_id":"98e7a2a31cc524921d66d59b73fd355f7df76d24","user":{"login":"TheDarkestDay","id":7871134,"avatar_url":"https://avatars1.githubusercontent.com/u/7871134?v=4","gravatar_id":"","url":"https://api.github.com/users/TheDarkestDay","html_url":"https://github.com/TheDarkestDay","followers_url":"https://api.github.com/users/TheDarkestDay/followers","following_url":"https://api.github.com/users/TheDarkestDay/following{/other_user}","gists_url":"https://api.github.com/users/TheDarkestDay/gists{/gist_id}","starred_url":"https://api.github.com/users/TheDarkestDay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheDarkestDay/subscriptions","organizations_url":"https://api.github.com/users/TheDarkestDay/orgs","repos_url":"https://api.github.com/users/TheDarkestDay/repos","events_url":"https://api.github.com/users/TheDarkestDay/events{/privacy}","received_events_url":"https://api.github.com/users/TheDarkestDay/received_events","type":"User","site_admin":false},"body":"А этот вовсе удалить.","created_at":"2018-02-22T15:50:54Z","updated_at":"2018-02-22T16:00:32Z","html_url":"https://github.com/htmlacademy-nodejs/157558-kekstagram/pull/8#discussion_r170001819","pull_request_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/pulls/8","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/pulls/comments/170001819"},"html":{"href":"https://github.com/htmlacademy-nodejs/157558-kekstagram/pull/8#discussion_r170001819"},"pull_request":{"href":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/pulls/8"}}},"pull_request":{"url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/pulls/8","id":170544391,"html_url":"https://github.com/htmlacademy-nodejs/157558-kekstagram/pull/8","diff_url":"https://github.com/htmlacademy-nodejs/157558-kekstagram/pull/8.diff","patch_url":"https://github.com/htmlacademy-nodejs/157558-kekstagram/pull/8.patch","issue_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/issues/8","number":8,"state":"open","locked":false,"title":"Запомнить всё","user":{"login":"inwisloklem","id":7903,"avatar_url":"https://avatars3.githubusercontent.com/u/7903?v=4","gravatar_id":"","url":"https://api.github.com/users/inwisloklem","html_url":"https://github.com/inwisloklem","followers_url":"https://api.github.com/users/inwisloklem/followers","following_url":"https://api.github.com/users/inwisloklem/following{/other_user}","gists_url":"https://api.github.com/users/inwisloklem/gists{/gist_id}","starred_url":"https://api.github.com/users/inwisloklem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inwisloklem/subscriptions","organizations_url":"https://api.github.com/users/inwisloklem/orgs","repos_url":"https://api.github.com/users/inwisloklem/repos","events_url":"https://api.github.com/users/inwisloklem/events{/privacy}","received_events_url":"https://api.github.com/users/inwisloklem/received_events","type":"User","site_admin":false},"body":"\n\n---\n:mortar_board: [Запомнить всё](https://up.htmlacademy.ru/nodejs/1/user/157558/tasks/9)","created_at":"2018-02-21T17:57:46Z","updated_at":"2018-02-22T16:00:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"54f00ada5caf058ad21dddc2ba4d743f62d16b5c","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/pulls/8/commits","review_comments_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/pulls/8/comments","review_comment_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/pulls/comments{/number}","comments_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/issues/8/comments","statuses_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/statuses/98e7a2a31cc524921d66d59b73fd355f7df76d24","head":{"label":"inwisloklem:module3-task3","ref":"module3-task3","sha":"98e7a2a31cc524921d66d59b73fd355f7df76d24","user":{"login":"inwisloklem","id":7903,"avatar_url":"https://avatars3.githubusercontent.com/u/7903?v=4","gravatar_id":"","url":"https://api.github.com/users/inwisloklem","html_url":"https://github.com/inwisloklem","followers_url":"https://api.github.com/users/inwisloklem/followers","following_url":"https://api.github.com/users/inwisloklem/following{/other_user}","gists_url":"https://api.github.com/users/inwisloklem/gists{/gist_id}","starred_url":"https://api.github.com/users/inwisloklem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inwisloklem/subscriptions","organizations_url":"https://api.github.com/users/inwisloklem/orgs","repos_url":"https://api.github.com/users/inwisloklem/repos","events_url":"https://api.github.com/users/inwisloklem/events{/privacy}","received_events_url":"https://api.github.com/users/inwisloklem/received_events","type":"User","site_admin":false},"repo":{"id":120482581,"name":"157558-kekstagram-1","full_name":"inwisloklem/157558-kekstagram-1","owner":{"login":"inwisloklem","id":7903,"avatar_url":"https://avatars3.githubusercontent.com/u/7903?v=4","gravatar_id":"","url":"https://api.github.com/users/inwisloklem","html_url":"https://github.com/inwisloklem","followers_url":"https://api.github.com/users/inwisloklem/followers","following_url":"https://api.github.com/users/inwisloklem/following{/other_user}","gists_url":"https://api.github.com/users/inwisloklem/gists{/gist_id}","starred_url":"https://api.github.com/users/inwisloklem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inwisloklem/subscriptions","organizations_url":"https://api.github.com/users/inwisloklem/orgs","repos_url":"https://api.github.com/users/inwisloklem/repos","events_url":"https://api.github.com/users/inwisloklem/events{/privacy}","received_events_url":"https://api.github.com/users/inwisloklem/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/inwisloklem/157558-kekstagram-1","description":"Илья Филиппов","fork":true,"url":"https://api.github.com/repos/inwisloklem/157558-kekstagram-1","forks_url":"https://api.github.com/repos/inwisloklem/157558-kekstagram-1/forks","keys_url":"https://api.github.com/repos/inwisloklem/157558-kekstagram-1/keys{/key_id}","collaborators_url":"https://api.github.com/repos/inwisloklem/157558-kekstagram-1/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/inwisloklem/157558-kekstagram-1/teams","hooks_url":"https://api.github.com/repos/inwisloklem/157558-kekstagram-1/hooks","issue_events_url":"https://api.github.com/repos/inwisloklem/157558-kekstagram-1/issues/events{/number}","events_url":"https://api.github.com/repos/inwisloklem/157558-kekstagram-1/events","assignees_url":"https://api.github.com/repos/inwisloklem/157558-kekstagram-1/assignees{/user}","branches_url":"https://api.github.com/repos/inwisloklem/157558-kekstagram-1/branches{/branch}","tags_url":"https://api.github.com/repos/inwisloklem/157558-kekstagram-1/tags","blobs_url":"https://api.github.com/repos/inwisloklem/157558-kekstagram-1/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/inwisloklem/157558-kekstagram-1/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/inwisloklem/157558-kekstagram-1/git/refs{/sha}","trees_url":"https://api.github.com/repos/inwisloklem/157558-kekstagram-1/git/trees{/sha}","statuses_url":"https://api.github.com/repos/inwisloklem/157558-kekstagram-1/statuses/{sha}","languages_url":"https://api.github.com/repos/inwisloklem/157558-kekstagram-1/languages","stargazers_url":"https://api.github.com/repos/inwisloklem/157558-kekstagram-1/stargazers","contributors_url":"https://api.github.com/repos/inwisloklem/157558-kekstagram-1/contributors","subscribers_url":"https://api.github.com/repos/inwisloklem/157558-kekstagram-1/subscribers","subscription_url":"https://api.github.com/repos/inwisloklem/157558-kekstagram-1/subscription","commits_url":"https://api.github.com/repos/inwisloklem/157558-kekstagram-1/commits{/sha}","git_commits_url":"https://api.github.com/repos/inwisloklem/157558-kekstagram-1/git/commits{/sha}","comments_url":"https://api.github.com/repos/inwisloklem/157558-kekstagram-1/comments{/number}","issue_comment_url":"https://api.github.com/repos/inwisloklem/157558-kekstagram-1/issues/comments{/number}","contents_url":"https://api.github.com/repos/inwisloklem/157558-kekstagram-1/contents/{+path}","compare_url":"https://api.github.com/repos/inwisloklem/157558-kekstagram-1/compare/{base}...{head}","merges_url":"https://api.github.com/repos/inwisloklem/157558-kekstagram-1/merges","archive_url":"https://api.github.com/repos/inwisloklem/157558-kekstagram-1/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/inwisloklem/157558-kekstagram-1/downloads","issues_url":"https://api.github.com/repos/inwisloklem/157558-kekstagram-1/issues{/number}","pulls_url":"https://api.github.com/repos/inwisloklem/157558-kekstagram-1/pulls{/number}","milestones_url":"https://api.github.com/repos/inwisloklem/157558-kekstagram-1/milestones{/number}","notifications_url":"https://api.github.com/repos/inwisloklem/157558-kekstagram-1/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/inwisloklem/157558-kekstagram-1/labels{/name}","releases_url":"https://api.github.com/repos/inwisloklem/157558-kekstagram-1/releases{/id}","deployments_url":"https://api.github.com/repos/inwisloklem/157558-kekstagram-1/deployments","created_at":"2018-02-06T15:52:44Z","updated_at":"2018-02-12T15:11:57Z","pushed_at":"2018-02-22T14:32:34Z","git_url":"git://github.com/inwisloklem/157558-kekstagram-1.git","ssh_url":"git@github.com:inwisloklem/157558-kekstagram-1.git","clone_url":"https://github.com/inwisloklem/157558-kekstagram-1.git","svn_url":"https://github.com/inwisloklem/157558-kekstagram-1","homepage":null,"size":59,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"htmlacademy-nodejs:master","ref":"master","sha":"e7c0c23ef9c6e55f0ba67c76555110aa89f69470","user":{"login":"htmlacademy-nodejs","id":23528374,"avatar_url":"https://avatars0.githubusercontent.com/u/23528374?v=4","gravatar_id":"","url":"https://api.github.com/users/htmlacademy-nodejs","html_url":"https://github.com/htmlacademy-nodejs","followers_url":"https://api.github.com/users/htmlacademy-nodejs/followers","following_url":"https://api.github.com/users/htmlacademy-nodejs/following{/other_user}","gists_url":"https://api.github.com/users/htmlacademy-nodejs/gists{/gist_id}","starred_url":"https://api.github.com/users/htmlacademy-nodejs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/htmlacademy-nodejs/subscriptions","organizations_url":"https://api.github.com/users/htmlacademy-nodejs/orgs","repos_url":"https://api.github.com/users/htmlacademy-nodejs/repos","events_url":"https://api.github.com/users/htmlacademy-nodejs/events{/privacy}","received_events_url":"https://api.github.com/users/htmlacademy-nodejs/received_events","type":"Organization","site_admin":false},"repo":{"id":120347954,"name":"157558-kekstagram","full_name":"htmlacademy-nodejs/157558-kekstagram","owner":{"login":"htmlacademy-nodejs","id":23528374,"avatar_url":"https://avatars0.githubusercontent.com/u/23528374?v=4","gravatar_id":"","url":"https://api.github.com/users/htmlacademy-nodejs","html_url":"https://github.com/htmlacademy-nodejs","followers_url":"https://api.github.com/users/htmlacademy-nodejs/followers","following_url":"https://api.github.com/users/htmlacademy-nodejs/following{/other_user}","gists_url":"https://api.github.com/users/htmlacademy-nodejs/gists{/gist_id}","starred_url":"https://api.github.com/users/htmlacademy-nodejs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/htmlacademy-nodejs/subscriptions","organizations_url":"https://api.github.com/users/htmlacademy-nodejs/orgs","repos_url":"https://api.github.com/users/htmlacademy-nodejs/repos","events_url":"https://api.github.com/users/htmlacademy-nodejs/events{/privacy}","received_events_url":"https://api.github.com/users/htmlacademy-nodejs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/htmlacademy-nodejs/157558-kekstagram","description":"Илья Филиппов","fork":false,"url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram","forks_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/forks","keys_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/keys{/key_id}","collaborators_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/teams","hooks_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/hooks","issue_events_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/issues/events{/number}","events_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/events","assignees_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/assignees{/user}","branches_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/branches{/branch}","tags_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/tags","blobs_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/git/refs{/sha}","trees_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/git/trees{/sha}","statuses_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/statuses/{sha}","languages_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/languages","stargazers_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/stargazers","contributors_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/contributors","subscribers_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/subscribers","subscription_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/subscription","commits_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/commits{/sha}","git_commits_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/git/commits{/sha}","comments_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/comments{/number}","issue_comment_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/issues/comments{/number}","contents_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/contents/{+path}","compare_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/compare/{base}...{head}","merges_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/merges","archive_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/downloads","issues_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/issues{/number}","pulls_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/pulls{/number}","milestones_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/milestones{/number}","notifications_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/labels{/name}","releases_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/releases{/id}","deployments_url":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/deployments","created_at":"2018-02-05T19:00:28Z","updated_at":"2018-02-08T10:15:21Z","pushed_at":"2018-02-22T14:32:35Z","git_url":"git://github.com/htmlacademy-nodejs/157558-kekstagram.git","ssh_url":"git@github.com:htmlacademy-nodejs/157558-kekstagram.git","clone_url":"https://github.com/htmlacademy-nodejs/157558-kekstagram.git","svn_url":"https://github.com/htmlacademy-nodejs/157558-kekstagram","homepage":"https://github.com/inwisloklem/157558-kekstagram-1","size":52,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/pulls/8"},"html":{"href":"https://github.com/htmlacademy-nodejs/157558-kekstagram/pull/8"},"issue":{"href":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/issues/8"},"comments":{"href":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/htmlacademy-nodejs/157558-kekstagram/statuses/98e7a2a31cc524921d66d59b73fd355f7df76d24"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"TheDarkestDay"}}