{"action":"created","comment":{"url":"https://api.github.com/repos/facebook/react-native/pulls/comments/78032706","id":78032706,"diff_hunk":"@@ -78,13 +78,108 @@ function tryRunAdbReverse(device) {\n // Builds the app and runs it on a connected emulator / device.\n function buildAndRun(args) {\n   process.chdir(path.join(args.root, 'android'));\n+  const cmd = process.platform.startsWith('win')\n+    ? 'gradlew.bat'\n+    : './gradlew';\n+\n+  const packageName = fs.readFileSync(\n+      'app/src/main/AndroidManifest.xml',\n+      'utf8'\n+    ).match(/package=\"(.+?)\"/)[1];\n+\n+  const adbPath = getAdbPath();\n+  if (args.deviceId) {\n+    runOnSpecificDevice(args, cmd, packageName, adbPath);\n+  } else {\n+    runOnAllDevices(args, cmd, packageName, adbPath);\n+  }\n+}\n+\n+function runOnSpecificDevice(args, cmd, packageName, adbPath) {\n+  let devices = adb.getDevices();\n+  let selectedDevice = findMatchingDevice(devices, args.deviceId);\n+  if (selectedDevice){\n+    buildApk(cmd);\n+    installAndLaunchOnDevice(args, selectedDevice, packageName, adbPath);\n+  } else {\n+      if (devices){\n+        console.log('Could not find device with the id: \"' + args.deviceId + '\".');\n+        console.log('Choose one of the following:');\n+        child_process.execFileSync('adb', ['devices'], {\n+          stdio: [process.stdin, process.stdout, process.stderr],\n+        });\n+      } else {\n+        console.log('No android devices connected.');\n+      }\n+  }\n+}\n+\n+function buildApk(cmd) {\n   try {\n-    adb.getDevices().map((device) => tryRunAdbReverse(device));\n+    console.log(chalk.bold(\n+      'Building the app...'\n+    ));\n+\n+    child_process.execFileSync(cmd, ['build', '-x', 'lint'], {","path":"local-cli/runAndroid/runAndroid.js","position":47,"original_position":47,"commit_id":"152a78612b79e5179344f0b5c7abe1922cd4010c","original_commit_id":"152a78612b79e5179344f0b5c7abe1922cd4010c","user":{"login":"mkonicek","id":346214,"avatar_url":"https://avatars.githubusercontent.com/u/346214?v=3","gravatar_id":"","url":"https://api.github.com/users/mkonicek","html_url":"https://github.com/mkonicek","followers_url":"https://api.github.com/users/mkonicek/followers","following_url":"https://api.github.com/users/mkonicek/following{/other_user}","gists_url":"https://api.github.com/users/mkonicek/gists{/gist_id}","starred_url":"https://api.github.com/users/mkonicek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkonicek/subscriptions","organizations_url":"https://api.github.com/users/mkonicek/orgs","repos_url":"https://api.github.com/users/mkonicek/repos","events_url":"https://api.github.com/users/mkonicek/events{/privacy}","received_events_url":"https://api.github.com/users/mkonicek/received_events","type":"User","site_admin":false},"body":"Maybe we should call the `cmd` `gradlew` - also in the function calls that call `buildApk`. This way it's more obvious it's always `gradlew` or `gradle.bat` command - it is, right?\r\n\r\nAt fist I got confused when I saw `build -x lint` being appended to a command and didn't know what the command could be.\r\n\r\nWhat does `-x lint` do? Can you add a comment above this line explaining why use `-x lint`?\r\n\r\n","created_at":"2016-09-08T15:43:11Z","updated_at":"2016-09-08T15:43:11Z","html_url":"https://github.com/facebook/react-native/pull/9568#discussion_r78032706","pull_request_url":"https://api.github.com/repos/facebook/react-native/pulls/9568","_links":{"self":{"href":"https://api.github.com/repos/facebook/react-native/pulls/comments/78032706"},"html":{"href":"https://github.com/facebook/react-native/pull/9568#discussion_r78032706"},"pull_request":{"href":"https://api.github.com/repos/facebook/react-native/pulls/9568"}}},"pull_request":{"url":"https://api.github.com/repos/facebook/react-native/pulls/9568","id":82535763,"html_url":"https://github.com/facebook/react-native/pull/9568","diff_url":"https://github.com/facebook/react-native/pull/9568.diff","patch_url":"https://github.com/facebook/react-native/pull/9568.patch","issue_url":"https://api.github.com/repos/facebook/react-native/issues/9568","number":9568,"state":"open","locked":false,"title":"run-android-on-specific-device","user":{"login":"LearningDave","id":9102810,"avatar_url":"https://avatars.githubusercontent.com/u/9102810?v=3","gravatar_id":"","url":"https://api.github.com/users/LearningDave","html_url":"https://github.com/LearningDave","followers_url":"https://api.github.com/users/LearningDave/followers","following_url":"https://api.github.com/users/LearningDave/following{/other_user}","gists_url":"https://api.github.com/users/LearningDave/gists{/gist_id}","starred_url":"https://api.github.com/users/LearningDave/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LearningDave/subscriptions","organizations_url":"https://api.github.com/users/LearningDave/orgs","repos_url":"https://api.github.com/users/LearningDave/repos","events_url":"https://api.github.com/users/LearningDave/events{/privacy}","received_events_url":"https://api.github.com/users/LearningDave/received_events","type":"User","site_admin":false},"body":"## **Summary**\r\nAt the moment the run-android command from the react-native cli does run all available devices at once. However it would be extreme useful to have the option to choose only one specific device/simulator.\r\nTherefore i've created a new flag for the command 'run-android': --deviceIdFromList 'deviceIdFromList' in order\r\nto install and launch apps on a specific device/simulator from the command line.\r\n\r\n'deviceIdFromList'  is the id listed on the output of the command 'adb devices'.\r\n\r\n## **Tests**:\r\nI've tested my code with the following commands:\r\nreact-native run-android --deviceIdFromList \"Not existing id\"\r\nreact-native run-android --deviceIdFromList \r\nreact-native run-android --deviceIdFromList \"id of a simulator\"\r\nreact-native run-android --deviceIdFromList \"id of a device\"\r\n\r\n\r\nOutput:\r\n![not-existing-device](https://cloud.githubusercontent.com/assets/9102810/17931086/d843abc8-6a09-11e6-995d-8c737dd5ed5c.png)\r\n![empty-flag](https://cloud.githubusercontent.com/assets/9102810/17931087/d8443930-6a09-11e6-94f3-d35aebfead88.png)\r\n![simulator-1](https://cloud.githubusercontent.com/assets/9102810/17931085/d843a240-6a09-11e6-887f-c17fcac6cd69.png)\r\n![simulator-2](https://cloud.githubusercontent.com/assets/9102810/17931084/d843525e-6a09-11e6-8a03-68cf2c420c8d.png)\r\n![device-id-1](https://cloud.githubusercontent.com/assets/9102810/17961788/0d0e5ef8-6aae-11e6-9599-288236d631fa.png)\r\n![device-id-2](https://cloud.githubusercontent.com/assets/9102810/17961787/0d0e2c58-6aae-11e6-82e2-47e5b15bc02e.png)\r\n\r\n\r\n\r\n","created_at":"2016-08-24T12:49:31Z","updated_at":"2016-09-08T15:43:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4f99718818851e75dd6f4b8f6c20fe8deee152b8","assignee":{"login":"mkonicek","id":346214,"avatar_url":"https://avatars.githubusercontent.com/u/346214?v=3","gravatar_id":"","url":"https://api.github.com/users/mkonicek","html_url":"https://github.com/mkonicek","followers_url":"https://api.github.com/users/mkonicek/followers","following_url":"https://api.github.com/users/mkonicek/following{/other_user}","gists_url":"https://api.github.com/users/mkonicek/gists{/gist_id}","starred_url":"https://api.github.com/users/mkonicek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkonicek/subscriptions","organizations_url":"https://api.github.com/users/mkonicek/orgs","repos_url":"https://api.github.com/users/mkonicek/repos","events_url":"https://api.github.com/users/mkonicek/events{/privacy}","received_events_url":"https://api.github.com/users/mkonicek/received_events","type":"User","site_admin":false},"assignees":[{"login":"mkonicek","id":346214,"avatar_url":"https://avatars.githubusercontent.com/u/346214?v=3","gravatar_id":"","url":"https://api.github.com/users/mkonicek","html_url":"https://github.com/mkonicek","followers_url":"https://api.github.com/users/mkonicek/followers","following_url":"https://api.github.com/users/mkonicek/following{/other_user}","gists_url":"https://api.github.com/users/mkonicek/gists{/gist_id}","starred_url":"https://api.github.com/users/mkonicek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkonicek/subscriptions","organizations_url":"https://api.github.com/users/mkonicek/orgs","repos_url":"https://api.github.com/users/mkonicek/repos","events_url":"https://api.github.com/users/mkonicek/events{/privacy}","received_events_url":"https://api.github.com/users/mkonicek/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/facebook/react-native/pulls/9568/commits","review_comments_url":"https://api.github.com/repos/facebook/react-native/pulls/9568/comments","review_comment_url":"https://api.github.com/repos/facebook/react-native/pulls/comments{/number}","comments_url":"https://api.github.com/repos/facebook/react-native/issues/9568/comments","statuses_url":"https://api.github.com/repos/facebook/react-native/statuses/152a78612b79e5179344f0b5c7abe1922cd4010c","head":{"label":"LearningDave:feat/run-android-on-specific-device","ref":"feat/run-android-on-specific-device","sha":"152a78612b79e5179344f0b5c7abe1922cd4010c","user":{"login":"LearningDave","id":9102810,"avatar_url":"https://avatars.githubusercontent.com/u/9102810?v=3","gravatar_id":"","url":"https://api.github.com/users/LearningDave","html_url":"https://github.com/LearningDave","followers_url":"https://api.github.com/users/LearningDave/followers","following_url":"https://api.github.com/users/LearningDave/following{/other_user}","gists_url":"https://api.github.com/users/LearningDave/gists{/gist_id}","starred_url":"https://api.github.com/users/LearningDave/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LearningDave/subscriptions","organizations_url":"https://api.github.com/users/LearningDave/orgs","repos_url":"https://api.github.com/users/LearningDave/repos","events_url":"https://api.github.com/users/LearningDave/events{/privacy}","received_events_url":"https://api.github.com/users/LearningDave/received_events","type":"User","site_admin":false},"repo":{"id":65739841,"name":"react-native","full_name":"LearningDave/react-native","owner":{"login":"LearningDave","id":9102810,"avatar_url":"https://avatars.githubusercontent.com/u/9102810?v=3","gravatar_id":"","url":"https://api.github.com/users/LearningDave","html_url":"https://github.com/LearningDave","followers_url":"https://api.github.com/users/LearningDave/followers","following_url":"https://api.github.com/users/LearningDave/following{/other_user}","gists_url":"https://api.github.com/users/LearningDave/gists{/gist_id}","starred_url":"https://api.github.com/users/LearningDave/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LearningDave/subscriptions","organizations_url":"https://api.github.com/users/LearningDave/orgs","repos_url":"https://api.github.com/users/LearningDave/repos","events_url":"https://api.github.com/users/LearningDave/events{/privacy}","received_events_url":"https://api.github.com/users/LearningDave/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/LearningDave/react-native","description":"A framework for building native apps with React.","fork":true,"url":"https://api.github.com/repos/LearningDave/react-native","forks_url":"https://api.github.com/repos/LearningDave/react-native/forks","keys_url":"https://api.github.com/repos/LearningDave/react-native/keys{/key_id}","collaborators_url":"https://api.github.com/repos/LearningDave/react-native/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/LearningDave/react-native/teams","hooks_url":"https://api.github.com/repos/LearningDave/react-native/hooks","issue_events_url":"https://api.github.com/repos/LearningDave/react-native/issues/events{/number}","events_url":"https://api.github.com/repos/LearningDave/react-native/events","assignees_url":"https://api.github.com/repos/LearningDave/react-native/assignees{/user}","branches_url":"https://api.github.com/repos/LearningDave/react-native/branches{/branch}","tags_url":"https://api.github.com/repos/LearningDave/react-native/tags","blobs_url":"https://api.github.com/repos/LearningDave/react-native/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/LearningDave/react-native/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/LearningDave/react-native/git/refs{/sha}","trees_url":"https://api.github.com/repos/LearningDave/react-native/git/trees{/sha}","statuses_url":"https://api.github.com/repos/LearningDave/react-native/statuses/{sha}","languages_url":"https://api.github.com/repos/LearningDave/react-native/languages","stargazers_url":"https://api.github.com/repos/LearningDave/react-native/stargazers","contributors_url":"https://api.github.com/repos/LearningDave/react-native/contributors","subscribers_url":"https://api.github.com/repos/LearningDave/react-native/subscribers","subscription_url":"https://api.github.com/repos/LearningDave/react-native/subscription","commits_url":"https://api.github.com/repos/LearningDave/react-native/commits{/sha}","git_commits_url":"https://api.github.com/repos/LearningDave/react-native/git/commits{/sha}","comments_url":"https://api.github.com/repos/LearningDave/react-native/comments{/number}","issue_comment_url":"https://api.github.com/repos/LearningDave/react-native/issues/comments{/number}","contents_url":"https://api.github.com/repos/LearningDave/react-native/contents/{+path}","compare_url":"https://api.github.com/repos/LearningDave/react-native/compare/{base}...{head}","merges_url":"https://api.github.com/repos/LearningDave/react-native/merges","archive_url":"https://api.github.com/repos/LearningDave/react-native/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/LearningDave/react-native/downloads","issues_url":"https://api.github.com/repos/LearningDave/react-native/issues{/number}","pulls_url":"https://api.github.com/repos/LearningDave/react-native/pulls{/number}","milestones_url":"https://api.github.com/repos/LearningDave/react-native/milestones{/number}","notifications_url":"https://api.github.com/repos/LearningDave/react-native/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/LearningDave/react-native/labels{/name}","releases_url":"https://api.github.com/repos/LearningDave/react-native/releases{/id}","deployments_url":"https://api.github.com/repos/LearningDave/react-native/deployments","created_at":"2016-08-15T14:47:18Z","updated_at":"2016-08-15T14:47:27Z","pushed_at":"2016-09-06T13:16:31Z","git_url":"git://github.com/LearningDave/react-native.git","ssh_url":"git@github.com:LearningDave/react-native.git","clone_url":"https://github.com/LearningDave/react-native.git","svn_url":"https://github.com/LearningDave/react-native","homepage":"http://facebook.github.io/react-native/","size":84486,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"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":0,"default_branch":"master"}},"base":{"label":"facebook:master","ref":"master","sha":"b4999fca0d783bfaeb47200e434760aae8badb14","user":{"login":"facebook","id":69631,"avatar_url":"https://avatars.githubusercontent.com/u/69631?v=3","gravatar_id":"","url":"https://api.github.com/users/facebook","html_url":"https://github.com/facebook","followers_url":"https://api.github.com/users/facebook/followers","following_url":"https://api.github.com/users/facebook/following{/other_user}","gists_url":"https://api.github.com/users/facebook/gists{/gist_id}","starred_url":"https://api.github.com/users/facebook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebook/subscriptions","organizations_url":"https://api.github.com/users/facebook/orgs","repos_url":"https://api.github.com/users/facebook/repos","events_url":"https://api.github.com/users/facebook/events{/privacy}","received_events_url":"https://api.github.com/users/facebook/received_events","type":"Organization","site_admin":false},"repo":{"id":29028775,"name":"react-native","full_name":"facebook/react-native","owner":{"login":"facebook","id":69631,"avatar_url":"https://avatars.githubusercontent.com/u/69631?v=3","gravatar_id":"","url":"https://api.github.com/users/facebook","html_url":"https://github.com/facebook","followers_url":"https://api.github.com/users/facebook/followers","following_url":"https://api.github.com/users/facebook/following{/other_user}","gists_url":"https://api.github.com/users/facebook/gists{/gist_id}","starred_url":"https://api.github.com/users/facebook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebook/subscriptions","organizations_url":"https://api.github.com/users/facebook/orgs","repos_url":"https://api.github.com/users/facebook/repos","events_url":"https://api.github.com/users/facebook/events{/privacy}","received_events_url":"https://api.github.com/users/facebook/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/facebook/react-native","description":"A framework for building native apps with React.","fork":false,"url":"https://api.github.com/repos/facebook/react-native","forks_url":"https://api.github.com/repos/facebook/react-native/forks","keys_url":"https://api.github.com/repos/facebook/react-native/keys{/key_id}","collaborators_url":"https://api.github.com/repos/facebook/react-native/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/facebook/react-native/teams","hooks_url":"https://api.github.com/repos/facebook/react-native/hooks","issue_events_url":"https://api.github.com/repos/facebook/react-native/issues/events{/number}","events_url":"https://api.github.com/repos/facebook/react-native/events","assignees_url":"https://api.github.com/repos/facebook/react-native/assignees{/user}","branches_url":"https://api.github.com/repos/facebook/react-native/branches{/branch}","tags_url":"https://api.github.com/repos/facebook/react-native/tags","blobs_url":"https://api.github.com/repos/facebook/react-native/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/facebook/react-native/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/facebook/react-native/git/refs{/sha}","trees_url":"https://api.github.com/repos/facebook/react-native/git/trees{/sha}","statuses_url":"https://api.github.com/repos/facebook/react-native/statuses/{sha}","languages_url":"https://api.github.com/repos/facebook/react-native/languages","stargazers_url":"https://api.github.com/repos/facebook/react-native/stargazers","contributors_url":"https://api.github.com/repos/facebook/react-native/contributors","subscribers_url":"https://api.github.com/repos/facebook/react-native/subscribers","subscription_url":"https://api.github.com/repos/facebook/react-native/subscription","commits_url":"https://api.github.com/repos/facebook/react-native/commits{/sha}","git_commits_url":"https://api.github.com/repos/facebook/react-native/git/commits{/sha}","comments_url":"https://api.github.com/repos/facebook/react-native/comments{/number}","issue_comment_url":"https://api.github.com/repos/facebook/react-native/issues/comments{/number}","contents_url":"https://api.github.com/repos/facebook/react-native/contents/{+path}","compare_url":"https://api.github.com/repos/facebook/react-native/compare/{base}...{head}","merges_url":"https://api.github.com/repos/facebook/react-native/merges","archive_url":"https://api.github.com/repos/facebook/react-native/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/facebook/react-native/downloads","issues_url":"https://api.github.com/repos/facebook/react-native/issues{/number}","pulls_url":"https://api.github.com/repos/facebook/react-native/pulls{/number}","milestones_url":"https://api.github.com/repos/facebook/react-native/milestones{/number}","notifications_url":"https://api.github.com/repos/facebook/react-native/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/facebook/react-native/labels{/name}","releases_url":"https://api.github.com/repos/facebook/react-native/releases{/id}","deployments_url":"https://api.github.com/repos/facebook/react-native/deployments","created_at":"2015-01-09T18:10:16Z","updated_at":"2016-09-08T14:41:59Z","pushed_at":"2016-09-08T15:35:13Z","git_url":"git://github.com/facebook/react-native.git","ssh_url":"git@github.com:facebook/react-native.git","clone_url":"https://github.com/facebook/react-native.git","svn_url":"https://github.com/facebook/react-native","homepage":"http://facebook.github.io/react-native/","size":129853,"stargazers_count":37333,"watchers_count":37333,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":8237,"mirror_url":null,"open_issues_count":1226,"forks":8237,"open_issues":1226,"watchers":37333,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/facebook/react-native/pulls/9568"},"html":{"href":"https://github.com/facebook/react-native/pull/9568"},"issue":{"href":"https://api.github.com/repos/facebook/react-native/issues/9568"},"comments":{"href":"https://api.github.com/repos/facebook/react-native/issues/9568/comments"},"review_comments":{"href":"https://api.github.com/repos/facebook/react-native/pulls/9568/comments"},"review_comment":{"href":"https://api.github.com/repos/facebook/react-native/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/facebook/react-native/pulls/9568/commits"},"statuses":{"href":"https://api.github.com/repos/facebook/react-native/statuses/152a78612b79e5179344f0b5c7abe1922cd4010c"}}}}
{"actor":{"display_login":"mkonicek"}}