{"action":"created","comment":{"url":"https://api.github.com/repos/uphold/github-changelog-generator/pulls/comments/170044416","pull_request_review_id":98657429,"id":170044416,"diff_hunk":"@@ -26,12 +27,42 @@ program\n  */\n \n const concurrency = 20;\n-const { futureRelease, owner, repo } = program;\n+const futureRelease = program.futureRelease;\n const futureReleaseTag = program.futureReleaseTag || futureRelease;\n+let { owner, repo } = program;\n const token = process.env.GITHUB_TOKEN;\n \n if (!owner || !repo) {\n-  process.stderr.write(`  Missing required options.\\n${program.helpInformation()}`);\n+  /**\n+   * Try to read missing values from package.json.\n+   */\n+\n+  let pjson;\n+\n+  try {\n+    pjson = require(`${process.cwd()}/package.json`);\n+  } catch (e) {\n+    process.stderr.write(`  Missing owner/repo values. Add package.json file with a valid repository value or provide --owner and --repo options.`);\n+\n+    process.exit(1);\n+  }\n+\n+  if (pjson && pjson.repository) {\n+    const repoUrl = pjson.repository.url || pjson.repository;\n+\n+    if (repoUrl) {\n+      const packageRepositoryData = gh(repoUrl);\n+\n+      if (packageRepositoryData) {\n+        owner = owner || packageRepositoryData.owner;\n+        repo = repo || packageRepositoryData.name;\n+      }\n+    }\n+  }\n+}\n+\n+if (!owner || !repo) {\n+  process.stderr.write(`  Missing owner/repo values. Check if package.json contains a valid repository value or provide --owner and --repo options.`);","path":"src/index.js","position":62,"original_position":62,"commit_id":"b60bccbe7f7d70dae9ff48675516a457d1687709","original_commit_id":"b60bccbe7f7d70dae9ff48675516a457d1687709","user":{"login":"kurayama","id":257346,"avatar_url":"https://avatars3.githubusercontent.com/u/257346?v=4","gravatar_id":"","url":"https://api.github.com/users/kurayama","html_url":"https://github.com/kurayama","followers_url":"https://api.github.com/users/kurayama/followers","following_url":"https://api.github.com/users/kurayama/following{/other_user}","gists_url":"https://api.github.com/users/kurayama/gists{/gist_id}","starred_url":"https://api.github.com/users/kurayama/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kurayama/subscriptions","organizations_url":"https://api.github.com/users/kurayama/orgs","repos_url":"https://api.github.com/users/kurayama/repos","events_url":"https://api.github.com/users/kurayama/events{/privacy}","received_events_url":"https://api.github.com/users/kurayama/received_events","type":"User","site_admin":false},"body":"This message seems to be almost a duplicate of the one above. Could the code be changed around to only do this check/exit once?\r\n\r\nEg. checking if the file exists before requiring it and avoid the try catch.","created_at":"2018-02-22T18:04:20Z","updated_at":"2018-02-22T18:06:19Z","html_url":"https://github.com/uphold/github-changelog-generator/pull/44#discussion_r170044416","pull_request_url":"https://api.github.com/repos/uphold/github-changelog-generator/pulls/44","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/uphold/github-changelog-generator/pulls/comments/170044416"},"html":{"href":"https://github.com/uphold/github-changelog-generator/pull/44#discussion_r170044416"},"pull_request":{"href":"https://api.github.com/repos/uphold/github-changelog-generator/pulls/44"}}},"pull_request":{"url":"https://api.github.com/repos/uphold/github-changelog-generator/pulls/44","id":169799002,"html_url":"https://github.com/uphold/github-changelog-generator/pull/44","diff_url":"https://github.com/uphold/github-changelog-generator/pull/44.diff","patch_url":"https://github.com/uphold/github-changelog-generator/pull/44.patch","issue_url":"https://api.github.com/repos/uphold/github-changelog-generator/issues/44","number":44,"state":"open","locked":false,"title":"Owner and repo default values from package.json","user":{"login":"marianacapelo","id":3236387,"avatar_url":"https://avatars1.githubusercontent.com/u/3236387?v=4","gravatar_id":"","url":"https://api.github.com/users/marianacapelo","html_url":"https://github.com/marianacapelo","followers_url":"https://api.github.com/users/marianacapelo/followers","following_url":"https://api.github.com/users/marianacapelo/following{/other_user}","gists_url":"https://api.github.com/users/marianacapelo/gists{/gist_id}","starred_url":"https://api.github.com/users/marianacapelo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marianacapelo/subscriptions","organizations_url":"https://api.github.com/users/marianacapelo/orgs","repos_url":"https://api.github.com/users/marianacapelo/repos","events_url":"https://api.github.com/users/marianacapelo/events{/privacy}","received_events_url":"https://api.github.com/users/marianacapelo/received_events","type":"User","site_admin":false},"body":"Closes #14.\r\n\r\nAdded usage of package.json `repository` field data to find owner and repo default values. Using [parse-github-url](https://www.npmjs.com/package/parse-github-url).","created_at":"2018-02-17T20:00:47Z","updated_at":"2018-02-22T18:06:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"eefa3cd7744fb0042953221126faec577d2c5eee","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/uphold/github-changelog-generator/pulls/44/commits","review_comments_url":"https://api.github.com/repos/uphold/github-changelog-generator/pulls/44/comments","review_comment_url":"https://api.github.com/repos/uphold/github-changelog-generator/pulls/comments{/number}","comments_url":"https://api.github.com/repos/uphold/github-changelog-generator/issues/44/comments","statuses_url":"https://api.github.com/repos/uphold/github-changelog-generator/statuses/b60bccbe7f7d70dae9ff48675516a457d1687709","head":{"label":"marianacapelo:feature-parsing-owner-repo-opts","ref":"feature-parsing-owner-repo-opts","sha":"b60bccbe7f7d70dae9ff48675516a457d1687709","user":{"login":"marianacapelo","id":3236387,"avatar_url":"https://avatars1.githubusercontent.com/u/3236387?v=4","gravatar_id":"","url":"https://api.github.com/users/marianacapelo","html_url":"https://github.com/marianacapelo","followers_url":"https://api.github.com/users/marianacapelo/followers","following_url":"https://api.github.com/users/marianacapelo/following{/other_user}","gists_url":"https://api.github.com/users/marianacapelo/gists{/gist_id}","starred_url":"https://api.github.com/users/marianacapelo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marianacapelo/subscriptions","organizations_url":"https://api.github.com/users/marianacapelo/orgs","repos_url":"https://api.github.com/users/marianacapelo/repos","events_url":"https://api.github.com/users/marianacapelo/events{/privacy}","received_events_url":"https://api.github.com/users/marianacapelo/received_events","type":"User","site_admin":false},"repo":{"id":121849280,"name":"github-changelog-generator","full_name":"marianacapelo/github-changelog-generator","owner":{"login":"marianacapelo","id":3236387,"avatar_url":"https://avatars1.githubusercontent.com/u/3236387?v=4","gravatar_id":"","url":"https://api.github.com/users/marianacapelo","html_url":"https://github.com/marianacapelo","followers_url":"https://api.github.com/users/marianacapelo/followers","following_url":"https://api.github.com/users/marianacapelo/following{/other_user}","gists_url":"https://api.github.com/users/marianacapelo/gists{/gist_id}","starred_url":"https://api.github.com/users/marianacapelo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marianacapelo/subscriptions","organizations_url":"https://api.github.com/users/marianacapelo/orgs","repos_url":"https://api.github.com/users/marianacapelo/repos","events_url":"https://api.github.com/users/marianacapelo/events{/privacy}","received_events_url":"https://api.github.com/users/marianacapelo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/marianacapelo/github-changelog-generator","description":"Generate changelog files from the project's GitHub PRs","fork":true,"url":"https://api.github.com/repos/marianacapelo/github-changelog-generator","forks_url":"https://api.github.com/repos/marianacapelo/github-changelog-generator/forks","keys_url":"https://api.github.com/repos/marianacapelo/github-changelog-generator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/marianacapelo/github-changelog-generator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/marianacapelo/github-changelog-generator/teams","hooks_url":"https://api.github.com/repos/marianacapelo/github-changelog-generator/hooks","issue_events_url":"https://api.github.com/repos/marianacapelo/github-changelog-generator/issues/events{/number}","events_url":"https://api.github.com/repos/marianacapelo/github-changelog-generator/events","assignees_url":"https://api.github.com/repos/marianacapelo/github-changelog-generator/assignees{/user}","branches_url":"https://api.github.com/repos/marianacapelo/github-changelog-generator/branches{/branch}","tags_url":"https://api.github.com/repos/marianacapelo/github-changelog-generator/tags","blobs_url":"https://api.github.com/repos/marianacapelo/github-changelog-generator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/marianacapelo/github-changelog-generator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/marianacapelo/github-changelog-generator/git/refs{/sha}","trees_url":"https://api.github.com/repos/marianacapelo/github-changelog-generator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/marianacapelo/github-changelog-generator/statuses/{sha}","languages_url":"https://api.github.com/repos/marianacapelo/github-changelog-generator/languages","stargazers_url":"https://api.github.com/repos/marianacapelo/github-changelog-generator/stargazers","contributors_url":"https://api.github.com/repos/marianacapelo/github-changelog-generator/contributors","subscribers_url":"https://api.github.com/repos/marianacapelo/github-changelog-generator/subscribers","subscription_url":"https://api.github.com/repos/marianacapelo/github-changelog-generator/subscription","commits_url":"https://api.github.com/repos/marianacapelo/github-changelog-generator/commits{/sha}","git_commits_url":"https://api.github.com/repos/marianacapelo/github-changelog-generator/git/commits{/sha}","comments_url":"https://api.github.com/repos/marianacapelo/github-changelog-generator/comments{/number}","issue_comment_url":"https://api.github.com/repos/marianacapelo/github-changelog-generator/issues/comments{/number}","contents_url":"https://api.github.com/repos/marianacapelo/github-changelog-generator/contents/{+path}","compare_url":"https://api.github.com/repos/marianacapelo/github-changelog-generator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/marianacapelo/github-changelog-generator/merges","archive_url":"https://api.github.com/repos/marianacapelo/github-changelog-generator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/marianacapelo/github-changelog-generator/downloads","issues_url":"https://api.github.com/repos/marianacapelo/github-changelog-generator/issues{/number}","pulls_url":"https://api.github.com/repos/marianacapelo/github-changelog-generator/pulls{/number}","milestones_url":"https://api.github.com/repos/marianacapelo/github-changelog-generator/milestones{/number}","notifications_url":"https://api.github.com/repos/marianacapelo/github-changelog-generator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/marianacapelo/github-changelog-generator/labels{/name}","releases_url":"https://api.github.com/repos/marianacapelo/github-changelog-generator/releases{/id}","deployments_url":"https://api.github.com/repos/marianacapelo/github-changelog-generator/deployments","created_at":"2018-02-17T11:20:58Z","updated_at":"2018-02-17T11:21:00Z","pushed_at":"2018-02-20T23:42:18Z","git_url":"git://github.com/marianacapelo/github-changelog-generator.git","ssh_url":"git@github.com:marianacapelo/github-changelog-generator.git","clone_url":"https://github.com/marianacapelo/github-changelog-generator.git","svn_url":"https://github.com/marianacapelo/github-changelog-generator","homepage":"","size":47,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"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":"uphold:master","ref":"master","sha":"dfa36e8bbbd3cf40cfeac3fee5700cd1c755a0fb","user":{"login":"uphold","id":7734494,"avatar_url":"https://avatars1.githubusercontent.com/u/7734494?v=4","gravatar_id":"","url":"https://api.github.com/users/uphold","html_url":"https://github.com/uphold","followers_url":"https://api.github.com/users/uphold/followers","following_url":"https://api.github.com/users/uphold/following{/other_user}","gists_url":"https://api.github.com/users/uphold/gists{/gist_id}","starred_url":"https://api.github.com/users/uphold/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uphold/subscriptions","organizations_url":"https://api.github.com/users/uphold/orgs","repos_url":"https://api.github.com/users/uphold/repos","events_url":"https://api.github.com/users/uphold/events{/privacy}","received_events_url":"https://api.github.com/users/uphold/received_events","type":"Organization","site_admin":false},"repo":{"id":74680677,"name":"github-changelog-generator","full_name":"uphold/github-changelog-generator","owner":{"login":"uphold","id":7734494,"avatar_url":"https://avatars1.githubusercontent.com/u/7734494?v=4","gravatar_id":"","url":"https://api.github.com/users/uphold","html_url":"https://github.com/uphold","followers_url":"https://api.github.com/users/uphold/followers","following_url":"https://api.github.com/users/uphold/following{/other_user}","gists_url":"https://api.github.com/users/uphold/gists{/gist_id}","starred_url":"https://api.github.com/users/uphold/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uphold/subscriptions","organizations_url":"https://api.github.com/users/uphold/orgs","repos_url":"https://api.github.com/users/uphold/repos","events_url":"https://api.github.com/users/uphold/events{/privacy}","received_events_url":"https://api.github.com/users/uphold/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/uphold/github-changelog-generator","description":"Generate changelog files from the project's GitHub PRs","fork":false,"url":"https://api.github.com/repos/uphold/github-changelog-generator","forks_url":"https://api.github.com/repos/uphold/github-changelog-generator/forks","keys_url":"https://api.github.com/repos/uphold/github-changelog-generator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/uphold/github-changelog-generator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/uphold/github-changelog-generator/teams","hooks_url":"https://api.github.com/repos/uphold/github-changelog-generator/hooks","issue_events_url":"https://api.github.com/repos/uphold/github-changelog-generator/issues/events{/number}","events_url":"https://api.github.com/repos/uphold/github-changelog-generator/events","assignees_url":"https://api.github.com/repos/uphold/github-changelog-generator/assignees{/user}","branches_url":"https://api.github.com/repos/uphold/github-changelog-generator/branches{/branch}","tags_url":"https://api.github.com/repos/uphold/github-changelog-generator/tags","blobs_url":"https://api.github.com/repos/uphold/github-changelog-generator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/uphold/github-changelog-generator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/uphold/github-changelog-generator/git/refs{/sha}","trees_url":"https://api.github.com/repos/uphold/github-changelog-generator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/uphold/github-changelog-generator/statuses/{sha}","languages_url":"https://api.github.com/repos/uphold/github-changelog-generator/languages","stargazers_url":"https://api.github.com/repos/uphold/github-changelog-generator/stargazers","contributors_url":"https://api.github.com/repos/uphold/github-changelog-generator/contributors","subscribers_url":"https://api.github.com/repos/uphold/github-changelog-generator/subscribers","subscription_url":"https://api.github.com/repos/uphold/github-changelog-generator/subscription","commits_url":"https://api.github.com/repos/uphold/github-changelog-generator/commits{/sha}","git_commits_url":"https://api.github.com/repos/uphold/github-changelog-generator/git/commits{/sha}","comments_url":"https://api.github.com/repos/uphold/github-changelog-generator/comments{/number}","issue_comment_url":"https://api.github.com/repos/uphold/github-changelog-generator/issues/comments{/number}","contents_url":"https://api.github.com/repos/uphold/github-changelog-generator/contents/{+path}","compare_url":"https://api.github.com/repos/uphold/github-changelog-generator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/uphold/github-changelog-generator/merges","archive_url":"https://api.github.com/repos/uphold/github-changelog-generator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/uphold/github-changelog-generator/downloads","issues_url":"https://api.github.com/repos/uphold/github-changelog-generator/issues{/number}","pulls_url":"https://api.github.com/repos/uphold/github-changelog-generator/pulls{/number}","milestones_url":"https://api.github.com/repos/uphold/github-changelog-generator/milestones{/number}","notifications_url":"https://api.github.com/repos/uphold/github-changelog-generator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/uphold/github-changelog-generator/labels{/name}","releases_url":"https://api.github.com/repos/uphold/github-changelog-generator/releases{/id}","deployments_url":"https://api.github.com/repos/uphold/github-changelog-generator/deployments","created_at":"2016-11-24T14:32:40Z","updated_at":"2018-02-21T11:12:23Z","pushed_at":"2018-02-21T11:02:23Z","git_url":"git://github.com/uphold/github-changelog-generator.git","ssh_url":"git@github.com:uphold/github-changelog-generator.git","clone_url":"https://github.com/uphold/github-changelog-generator.git","svn_url":"https://github.com/uphold/github-changelog-generator","homepage":"","size":45,"stargazers_count":4,"watchers_count":4,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":12,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":1,"open_issues":12,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/uphold/github-changelog-generator/pulls/44"},"html":{"href":"https://github.com/uphold/github-changelog-generator/pull/44"},"issue":{"href":"https://api.github.com/repos/uphold/github-changelog-generator/issues/44"},"comments":{"href":"https://api.github.com/repos/uphold/github-changelog-generator/issues/44/comments"},"review_comments":{"href":"https://api.github.com/repos/uphold/github-changelog-generator/pulls/44/comments"},"review_comment":{"href":"https://api.github.com/repos/uphold/github-changelog-generator/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/uphold/github-changelog-generator/pulls/44/commits"},"statuses":{"href":"https://api.github.com/repos/uphold/github-changelog-generator/statuses/b60bccbe7f7d70dae9ff48675516a457d1687709"}},"author_association":"NONE"}}
{"actor":{"display_login":"kurayama"}}