{"action":"created","comment":{"url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/pulls/comments/89199106","pull_request_review_id":9726886,"id":89199106,"diff_hunk":"@@ -3,90 +3,60 @@\n \n const fs = require('fs');\n const inquirer = require('inquirer');\n-\n-const questions = [\n-    {\n-        type: 'list',\n-        name: 'type',\n-        message: 'Select the type of change that you\\'re committing:',\n-        choices: [{\n-            name: '🐛     Fixing a bug',\n-            value: ':bug:'\n-        }, {\n-            name: '✨     Further development',\n-            value: ':sparkles:'\n-        }, {\n-            name: '✅     Adding tests',\n-            value: ':white_check_mark:'\n-        }, {\n-            name: '🎨     Improving the format/structure of the code',\n-            value: ':art:'\n-        }, {\n-            name: '📝     Writing docs',\n-            value: ':memo:'\n-        }, {\n-            name: '🏇     Improving performance',\n-            value: ':racehorse:'\n-        }, {\n-            name: '🚱     Plugging memory leaks',\n-            value: ':non-potable_water:'\n-        }, {\n-            name: '🔥     When removing code or files',\n-            value: ':fire:'\n-        }, {\n-            name: '💚     Fixing the CI build',\n-            value: ':green_heart:'\n-        }, {\n-            name: '🔒     Dealing with security',\n-            value: ':lock:'\n-        }, {\n-            name: '⬆️     Upgrading dependencies',\n-            value: ':arrow_up:'\n-        }, {\n-            name: '⬇️     Downgrading dependencies',\n-            value: ':arrow_down:'\n-        }, {\n-            name: '👕     Removing linter warnings',\n-            value: ':shirt:'\n-        }, {\n-            name: '🐧     Fixing something on Linux',\n-            value: ':penguin:'\n-        }, {\n-            name: '🍎     Fixing something on Mac OS',\n-            value: ':apple:'\n-        }, {\n-            name: '🏁     Fixing something on Windows',\n-            value: ':checkered_flag:'\n-        }, {\n-            name: '🐥     Add or update config files like .gitignore',\n-            value: ':hatched_chick:'\n-        }, {\n-            name: '⚡     Add a new feature',\n-            value: ':zap:'\n-        }, {\n-            name: `🌵     I don't like emojis`,\n-            value: ''\n-        }]\n-    }, {\n-        type: 'input',\n-        name: 'issue',\n-        message: 'Issue number'\n-    }\n-];\n-\n-const writeCommitMessage = answers => {\n-\n-    let commitMsg = fs.readFileSync(process.argv[2]);\n-\n-    const emoji = answers.type;\n-    const issue = answers.issue ? `#${answers.issue} ` : '';\n-    commitMsg = `${emoji} ${issue}\\n${commitMsg}`;\n-\n-    fs.writeFileSync(process.argv[2], commitMsg);\n-\n-    process.exit(0);\n-};\n-\n-if(/COMMIT_EDITMSG/g.test(process.argv[2])) {\n-    inquirer.prompt(questions, writeCommitMessage);\n+const axios = require('axios');\n+const chalk = require('chalk');\n+const pathExists = require('path-exists');\n+\n+const gitmojis = 'https://raw.githubusercontent.com/carloscuesta/gitmoji/master/src/data/gitmojis.json';\n+\n+let questions = []\n+\n+if (process.argv[2] === '--init') {\n+  if (pathExists.sync('.git')) {\n+    const path = `${process.env.PWD}/.git/hooks`;\n+\n+    fs.writeFile(`${path}/prepare-commit-msg`, `#!/bin/sh\\nexec < /dev/tty\\ngitmoji-commit-hook $1`, (err) => {\n+      if (err) {\n+        console.error(chalk.red(`🚨  ERROR: ${err}`));\n+      } else {\n+        console.log(`${chalk.green('🎉  SUCCESS 🎉')}  gitmoji-commit-hook initialized with success.`);\n+      }\n+    });\n+\n+    fs.chmod(`${path}/prepare-commit-msg`, '755', (err) => {\n+      if (err) {\n+        console.error(chalk.red(`🚨  ERROR: ${err}`));\n+      }\n+    });\n+  } else {\n+    console.error(chalk.red('🚨  ERROR: The directory is not a git repository.'));\n+  }\n+} else {\n+  axios.get(gitmojis)\n+    .then(res => {\n+      questions.push({\n+        type: 'checkbox',\n+        name: 'emoji',\n+        message: 'Select emoji(s) for your commit',\n+        choices: res.data.gitmojis.map(gitmoji => {\n+          return {\n+            name: gitmoji.emoji + '  ' + gitmoji.description,\n+            value: gitmoji.emoji\n+          };\n+        })\n+      });\n+\n+      if(/COMMIT_EDITMSG/g.test(process.argv[2])) {\n+        inquirer.prompt(questions).then((answers) => {","path":"bin/index.js","position":134,"original_position":134,"commit_id":"0a64fc1c2177f69ee96e45622fb866a551df47e2","original_commit_id":"0a64fc1c2177f69ee96e45622fb866a551df47e2","user":{"login":"tjoskar","id":1525612,"avatar_url":"https://avatars.githubusercontent.com/u/1525612?v=3","gravatar_id":"","url":"https://api.github.com/users/tjoskar","html_url":"https://github.com/tjoskar","followers_url":"https://api.github.com/users/tjoskar/followers","following_url":"https://api.github.com/users/tjoskar/following{/other_user}","gists_url":"https://api.github.com/users/tjoskar/gists{/gist_id}","starred_url":"https://api.github.com/users/tjoskar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tjoskar/subscriptions","organizations_url":"https://api.github.com/users/tjoskar/orgs","repos_url":"https://api.github.com/users/tjoskar/repos","events_url":"https://api.github.com/users/tjoskar/events{/privacy}","received_events_url":"https://api.github.com/users/tjoskar/received_events","type":"User","site_admin":false},"body":"We should return `inquirer.prompt` so we can catch (line 59) any errors that inquirer might give.","created_at":"2016-11-22T20:03:20Z","updated_at":"2016-11-22T20:14:44Z","html_url":"https://github.com/tjoskar/emoji-commit-hook/pull/2#discussion_r89199106","pull_request_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/tjoskar/emoji-commit-hook/pulls/comments/89199106"},"html":{"href":"https://github.com/tjoskar/emoji-commit-hook/pull/2#discussion_r89199106"},"pull_request":{"href":"https://api.github.com/repos/tjoskar/emoji-commit-hook/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/pulls/2","id":94619424,"html_url":"https://github.com/tjoskar/emoji-commit-hook/pull/2","diff_url":"https://github.com/tjoskar/emoji-commit-hook/pull/2.diff","patch_url":"https://github.com/tjoskar/emoji-commit-hook/pull/2.patch","issue_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/issues/2","number":2,"state":"open","locked":false,"title":"Huge changes","user":{"login":"welcoMattic","id":773875,"avatar_url":"https://avatars.githubusercontent.com/u/773875?v=3","gravatar_id":"","url":"https://api.github.com/users/welcoMattic","html_url":"https://github.com/welcoMattic","followers_url":"https://api.github.com/users/welcoMattic/followers","following_url":"https://api.github.com/users/welcoMattic/following{/other_user}","gists_url":"https://api.github.com/users/welcoMattic/gists{/gist_id}","starred_url":"https://api.github.com/users/welcoMattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/welcoMattic/subscriptions","organizations_url":"https://api.github.com/users/welcoMattic/orgs","repos_url":"https://api.github.com/users/welcoMattic/repos","events_url":"https://api.github.com/users/welcoMattic/events{/privacy}","received_events_url":"https://api.github.com/users/welcoMattic/received_events","type":"User","site_admin":false},"body":"- Refacto\r\n- Replace emojis list with [gitmoji](https://gitmoji.carloscuesta.me)\r\n- Add --init option\r\n","created_at":"2016-11-21T13:56:12Z","updated_at":"2016-11-22T20:14:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9effe12b7d7fc502349063e2e6a0c4883370ca5b","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/pulls/2/commits","review_comments_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/pulls/2/comments","review_comment_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/issues/2/comments","statuses_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/statuses/0a64fc1c2177f69ee96e45622fb866a551df47e2","head":{"label":"welcoMattic:master","ref":"master","sha":"0a64fc1c2177f69ee96e45622fb866a551df47e2","user":{"login":"welcoMattic","id":773875,"avatar_url":"https://avatars.githubusercontent.com/u/773875?v=3","gravatar_id":"","url":"https://api.github.com/users/welcoMattic","html_url":"https://github.com/welcoMattic","followers_url":"https://api.github.com/users/welcoMattic/followers","following_url":"https://api.github.com/users/welcoMattic/following{/other_user}","gists_url":"https://api.github.com/users/welcoMattic/gists{/gist_id}","starred_url":"https://api.github.com/users/welcoMattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/welcoMattic/subscriptions","organizations_url":"https://api.github.com/users/welcoMattic/orgs","repos_url":"https://api.github.com/users/welcoMattic/repos","events_url":"https://api.github.com/users/welcoMattic/events{/privacy}","received_events_url":"https://api.github.com/users/welcoMattic/received_events","type":"User","site_admin":false},"repo":{"id":74004578,"name":"gitmoji-commit-hook","full_name":"welcoMattic/gitmoji-commit-hook","owner":{"login":"welcoMattic","id":773875,"avatar_url":"https://avatars.githubusercontent.com/u/773875?v=3","gravatar_id":"","url":"https://api.github.com/users/welcoMattic","html_url":"https://github.com/welcoMattic","followers_url":"https://api.github.com/users/welcoMattic/followers","following_url":"https://api.github.com/users/welcoMattic/following{/other_user}","gists_url":"https://api.github.com/users/welcoMattic/gists{/gist_id}","starred_url":"https://api.github.com/users/welcoMattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/welcoMattic/subscriptions","organizations_url":"https://api.github.com/users/welcoMattic/orgs","repos_url":"https://api.github.com/users/welcoMattic/repos","events_url":"https://api.github.com/users/welcoMattic/events{/privacy}","received_events_url":"https://api.github.com/users/welcoMattic/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/welcoMattic/gitmoji-commit-hook","description":"✨ Start the commit message with an right emoji","fork":true,"url":"https://api.github.com/repos/welcoMattic/gitmoji-commit-hook","forks_url":"https://api.github.com/repos/welcoMattic/gitmoji-commit-hook/forks","keys_url":"https://api.github.com/repos/welcoMattic/gitmoji-commit-hook/keys{/key_id}","collaborators_url":"https://api.github.com/repos/welcoMattic/gitmoji-commit-hook/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/welcoMattic/gitmoji-commit-hook/teams","hooks_url":"https://api.github.com/repos/welcoMattic/gitmoji-commit-hook/hooks","issue_events_url":"https://api.github.com/repos/welcoMattic/gitmoji-commit-hook/issues/events{/number}","events_url":"https://api.github.com/repos/welcoMattic/gitmoji-commit-hook/events","assignees_url":"https://api.github.com/repos/welcoMattic/gitmoji-commit-hook/assignees{/user}","branches_url":"https://api.github.com/repos/welcoMattic/gitmoji-commit-hook/branches{/branch}","tags_url":"https://api.github.com/repos/welcoMattic/gitmoji-commit-hook/tags","blobs_url":"https://api.github.com/repos/welcoMattic/gitmoji-commit-hook/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/welcoMattic/gitmoji-commit-hook/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/welcoMattic/gitmoji-commit-hook/git/refs{/sha}","trees_url":"https://api.github.com/repos/welcoMattic/gitmoji-commit-hook/git/trees{/sha}","statuses_url":"https://api.github.com/repos/welcoMattic/gitmoji-commit-hook/statuses/{sha}","languages_url":"https://api.github.com/repos/welcoMattic/gitmoji-commit-hook/languages","stargazers_url":"https://api.github.com/repos/welcoMattic/gitmoji-commit-hook/stargazers","contributors_url":"https://api.github.com/repos/welcoMattic/gitmoji-commit-hook/contributors","subscribers_url":"https://api.github.com/repos/welcoMattic/gitmoji-commit-hook/subscribers","subscription_url":"https://api.github.com/repos/welcoMattic/gitmoji-commit-hook/subscription","commits_url":"https://api.github.com/repos/welcoMattic/gitmoji-commit-hook/commits{/sha}","git_commits_url":"https://api.github.com/repos/welcoMattic/gitmoji-commit-hook/git/commits{/sha}","comments_url":"https://api.github.com/repos/welcoMattic/gitmoji-commit-hook/comments{/number}","issue_comment_url":"https://api.github.com/repos/welcoMattic/gitmoji-commit-hook/issues/comments{/number}","contents_url":"https://api.github.com/repos/welcoMattic/gitmoji-commit-hook/contents/{+path}","compare_url":"https://api.github.com/repos/welcoMattic/gitmoji-commit-hook/compare/{base}...{head}","merges_url":"https://api.github.com/repos/welcoMattic/gitmoji-commit-hook/merges","archive_url":"https://api.github.com/repos/welcoMattic/gitmoji-commit-hook/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/welcoMattic/gitmoji-commit-hook/downloads","issues_url":"https://api.github.com/repos/welcoMattic/gitmoji-commit-hook/issues{/number}","pulls_url":"https://api.github.com/repos/welcoMattic/gitmoji-commit-hook/pulls{/number}","milestones_url":"https://api.github.com/repos/welcoMattic/gitmoji-commit-hook/milestones{/number}","notifications_url":"https://api.github.com/repos/welcoMattic/gitmoji-commit-hook/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/welcoMattic/gitmoji-commit-hook/labels{/name}","releases_url":"https://api.github.com/repos/welcoMattic/gitmoji-commit-hook/releases{/id}","deployments_url":"https://api.github.com/repos/welcoMattic/gitmoji-commit-hook/deployments","created_at":"2016-11-17T08:09:10Z","updated_at":"2016-11-19T18:37:39Z","pushed_at":"2016-11-22T14:24:14Z","git_url":"git://github.com/welcoMattic/gitmoji-commit-hook.git","ssh_url":"git@github.com:welcoMattic/gitmoji-commit-hook.git","clone_url":"https://github.com/welcoMattic/gitmoji-commit-hook.git","svn_url":"https://github.com/welcoMattic/gitmoji-commit-hook","homepage":"","size":1170,"stargazers_count":6,"watchers_count":6,"language":"JavaScript","has_issues":true,"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":6,"default_branch":"master"}},"base":{"label":"tjoskar:master","ref":"master","sha":"1f30796523fb4ad0b60815b2e0d05d7960f32d7f","user":{"login":"tjoskar","id":1525612,"avatar_url":"https://avatars.githubusercontent.com/u/1525612?v=3","gravatar_id":"","url":"https://api.github.com/users/tjoskar","html_url":"https://github.com/tjoskar","followers_url":"https://api.github.com/users/tjoskar/followers","following_url":"https://api.github.com/users/tjoskar/following{/other_user}","gists_url":"https://api.github.com/users/tjoskar/gists{/gist_id}","starred_url":"https://api.github.com/users/tjoskar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tjoskar/subscriptions","organizations_url":"https://api.github.com/users/tjoskar/orgs","repos_url":"https://api.github.com/users/tjoskar/repos","events_url":"https://api.github.com/users/tjoskar/events{/privacy}","received_events_url":"https://api.github.com/users/tjoskar/received_events","type":"User","site_admin":false},"repo":{"id":47421552,"name":"emoji-commit-hook","full_name":"tjoskar/emoji-commit-hook","owner":{"login":"tjoskar","id":1525612,"avatar_url":"https://avatars.githubusercontent.com/u/1525612?v=3","gravatar_id":"","url":"https://api.github.com/users/tjoskar","html_url":"https://github.com/tjoskar","followers_url":"https://api.github.com/users/tjoskar/followers","following_url":"https://api.github.com/users/tjoskar/following{/other_user}","gists_url":"https://api.github.com/users/tjoskar/gists{/gist_id}","starred_url":"https://api.github.com/users/tjoskar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tjoskar/subscriptions","organizations_url":"https://api.github.com/users/tjoskar/orgs","repos_url":"https://api.github.com/users/tjoskar/repos","events_url":"https://api.github.com/users/tjoskar/events{/privacy}","received_events_url":"https://api.github.com/users/tjoskar/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tjoskar/emoji-commit-hook","description":"Start the commit message with an applicable emoji","fork":false,"url":"https://api.github.com/repos/tjoskar/emoji-commit-hook","forks_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/forks","keys_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/teams","hooks_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/hooks","issue_events_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/issues/events{/number}","events_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/events","assignees_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/assignees{/user}","branches_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/branches{/branch}","tags_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/tags","blobs_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/git/refs{/sha}","trees_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/statuses/{sha}","languages_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/languages","stargazers_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/stargazers","contributors_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/contributors","subscribers_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/subscribers","subscription_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/subscription","commits_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/commits{/sha}","git_commits_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/git/commits{/sha}","comments_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/comments{/number}","issue_comment_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/issues/comments{/number}","contents_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/contents/{+path}","compare_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/merges","archive_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/downloads","issues_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/issues{/number}","pulls_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/pulls{/number}","milestones_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/milestones{/number}","notifications_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/labels{/name}","releases_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/releases{/id}","deployments_url":"https://api.github.com/repos/tjoskar/emoji-commit-hook/deployments","created_at":"2015-12-04T18:20:50Z","updated_at":"2016-11-17T19:33:34Z","pushed_at":"2016-11-22T14:24:14Z","git_url":"git://github.com/tjoskar/emoji-commit-hook.git","ssh_url":"git@github.com:tjoskar/emoji-commit-hook.git","clone_url":"https://github.com/tjoskar/emoji-commit-hook.git","svn_url":"https://github.com/tjoskar/emoji-commit-hook","homepage":null,"size":473,"stargazers_count":8,"watchers_count":8,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":8,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tjoskar/emoji-commit-hook/pulls/2"},"html":{"href":"https://github.com/tjoskar/emoji-commit-hook/pull/2"},"issue":{"href":"https://api.github.com/repos/tjoskar/emoji-commit-hook/issues/2"},"comments":{"href":"https://api.github.com/repos/tjoskar/emoji-commit-hook/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/tjoskar/emoji-commit-hook/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/tjoskar/emoji-commit-hook/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tjoskar/emoji-commit-hook/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/tjoskar/emoji-commit-hook/statuses/0a64fc1c2177f69ee96e45622fb866a551df47e2"}}}}
{"actor":{"display_login":"tjoskar"}}