{"action":"created","comment":{"url":"https://api.github.com/repos/tessel/t2-cli/pulls/comments/70515778","id":70515778,"diff_hunk":"@@ -144,13 +147,22 @@ USB.Connection.prototype.open = function() {\n           if (err) {\n             reject(err);\n           } else {\n-            resolve(data);\n+            this.serialNumber = data;\n+            resolve();\n           }\n         });\n       });\n-    })\n-    .then((data) => {\n-      this.serialNumber = data;\n+    });\n+\n+  if (altSetting === 1) {","path":"lib/usb-connection.js","position":36,"original_position":36,"commit_id":"876c169f67199c9f460a84d52feb20164c111e1d","original_commit_id":"876c169f67199c9f460a84d52feb20164c111e1d","user":{"login":"HipsterBrown","id":3051193,"avatar_url":"https://avatars.githubusercontent.com/u/3051193?v=3","gravatar_id":"","url":"https://api.github.com/users/HipsterBrown","html_url":"https://github.com/HipsterBrown","followers_url":"https://api.github.com/users/HipsterBrown/followers","following_url":"https://api.github.com/users/HipsterBrown/following{/other_user}","gists_url":"https://api.github.com/users/HipsterBrown/gists{/gist_id}","starred_url":"https://api.github.com/users/HipsterBrown/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HipsterBrown/subscriptions","organizations_url":"https://api.github.com/users/HipsterBrown/orgs","repos_url":"https://api.github.com/users/HipsterBrown/repos","events_url":"https://api.github.com/users/HipsterBrown/events{/privacy}","received_events_url":"https://api.github.com/users/HipsterBrown/received_events","type":"User","site_admin":false},"body":"I don't understand why this logic is done outside the Promise? `this.setAltSetting(altSetting)` could be returned instead of saved to a variable, and this logic could be done inside the next `.then()` statement:\r\n \r\nfrom line 156\r\n```js\r\n...\r\n.then(() => {\r\n    if (altSetting === 1) {\r\n        return Promise.resolve(this);\r\n    } else {\r\n        // everything else past line 167\r\n        ...\r\n    }\r\n});\r\n```\r\n\r\nThis should reduce some of the complexity of passing around a Promise, as well as ensure the error case is handled in one place. ","created_at":"2016-07-12T20:28:34Z","updated_at":"2016-07-12T20:28:34Z","html_url":"https://github.com/tessel/t2-cli/pull/744#discussion_r70515778","pull_request_url":"https://api.github.com/repos/tessel/t2-cli/pulls/744","_links":{"self":{"href":"https://api.github.com/repos/tessel/t2-cli/pulls/comments/70515778"},"html":{"href":"https://github.com/tessel/t2-cli/pull/744#discussion_r70515778"},"pull_request":{"href":"https://api.github.com/repos/tessel/t2-cli/pulls/744"}}},"pull_request":{"url":"https://api.github.com/repos/tessel/t2-cli/pulls/744","id":70464791,"html_url":"https://github.com/tessel/t2-cli/pull/744","diff_url":"https://github.com/tessel/t2-cli/pull/744.diff","patch_url":"https://github.com/tessel/t2-cli/pull/744.patch","issue_url":"https://api.github.com/repos/tessel/t2-cli/issues/744","number":744,"state":"open","locked":false,"title":"Unbrick openwrt","user":{"login":"majgis","id":546259,"avatar_url":"https://avatars.githubusercontent.com/u/546259?v=3","gravatar_id":"","url":"https://api.github.com/users/majgis","html_url":"https://github.com/majgis","followers_url":"https://api.github.com/users/majgis/followers","following_url":"https://api.github.com/users/majgis/following{/other_user}","gists_url":"https://api.github.com/users/majgis/gists{/gist_id}","starred_url":"https://api.github.com/users/majgis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/majgis/subscriptions","organizations_url":"https://api.github.com/users/majgis/orgs","repos_url":"https://api.github.com/users/majgis/repos","events_url":"https://api.github.com/users/majgis/events{/privacy}","received_events_url":"https://api.github.com/users/majgis/received_events","type":"User","site_admin":false},"body":"This fixes #493 ","created_at":"2016-05-18T03:38:21Z","updated_at":"2016-07-12T20:28:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"06cf23f63433e547d3f3c51694a841ef00368ab1","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/tessel/t2-cli/pulls/744/commits","review_comments_url":"https://api.github.com/repos/tessel/t2-cli/pulls/744/comments","review_comment_url":"https://api.github.com/repos/tessel/t2-cli/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tessel/t2-cli/issues/744/comments","statuses_url":"https://api.github.com/repos/tessel/t2-cli/statuses/876c169f67199c9f460a84d52feb20164c111e1d","head":{"label":"majgis:unbrick-rb3","ref":"unbrick-rb3","sha":"876c169f67199c9f460a84d52feb20164c111e1d","user":{"login":"majgis","id":546259,"avatar_url":"https://avatars.githubusercontent.com/u/546259?v=3","gravatar_id":"","url":"https://api.github.com/users/majgis","html_url":"https://github.com/majgis","followers_url":"https://api.github.com/users/majgis/followers","following_url":"https://api.github.com/users/majgis/following{/other_user}","gists_url":"https://api.github.com/users/majgis/gists{/gist_id}","starred_url":"https://api.github.com/users/majgis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/majgis/subscriptions","organizations_url":"https://api.github.com/users/majgis/orgs","repos_url":"https://api.github.com/users/majgis/repos","events_url":"https://api.github.com/users/majgis/events{/privacy}","received_events_url":"https://api.github.com/users/majgis/received_events","type":"User","site_admin":false},"repo":{"id":56394221,"name":"t2-cli","full_name":"majgis/t2-cli","owner":{"login":"majgis","id":546259,"avatar_url":"https://avatars.githubusercontent.com/u/546259?v=3","gravatar_id":"","url":"https://api.github.com/users/majgis","html_url":"https://github.com/majgis","followers_url":"https://api.github.com/users/majgis/followers","following_url":"https://api.github.com/users/majgis/following{/other_user}","gists_url":"https://api.github.com/users/majgis/gists{/gist_id}","starred_url":"https://api.github.com/users/majgis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/majgis/subscriptions","organizations_url":"https://api.github.com/users/majgis/orgs","repos_url":"https://api.github.com/users/majgis/repos","events_url":"https://api.github.com/users/majgis/events{/privacy}","received_events_url":"https://api.github.com/users/majgis/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/majgis/t2-cli","description":"Command line interface to Tessel 2.","fork":true,"url":"https://api.github.com/repos/majgis/t2-cli","forks_url":"https://api.github.com/repos/majgis/t2-cli/forks","keys_url":"https://api.github.com/repos/majgis/t2-cli/keys{/key_id}","collaborators_url":"https://api.github.com/repos/majgis/t2-cli/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/majgis/t2-cli/teams","hooks_url":"https://api.github.com/repos/majgis/t2-cli/hooks","issue_events_url":"https://api.github.com/repos/majgis/t2-cli/issues/events{/number}","events_url":"https://api.github.com/repos/majgis/t2-cli/events","assignees_url":"https://api.github.com/repos/majgis/t2-cli/assignees{/user}","branches_url":"https://api.github.com/repos/majgis/t2-cli/branches{/branch}","tags_url":"https://api.github.com/repos/majgis/t2-cli/tags","blobs_url":"https://api.github.com/repos/majgis/t2-cli/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/majgis/t2-cli/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/majgis/t2-cli/git/refs{/sha}","trees_url":"https://api.github.com/repos/majgis/t2-cli/git/trees{/sha}","statuses_url":"https://api.github.com/repos/majgis/t2-cli/statuses/{sha}","languages_url":"https://api.github.com/repos/majgis/t2-cli/languages","stargazers_url":"https://api.github.com/repos/majgis/t2-cli/stargazers","contributors_url":"https://api.github.com/repos/majgis/t2-cli/contributors","subscribers_url":"https://api.github.com/repos/majgis/t2-cli/subscribers","subscription_url":"https://api.github.com/repos/majgis/t2-cli/subscription","commits_url":"https://api.github.com/repos/majgis/t2-cli/commits{/sha}","git_commits_url":"https://api.github.com/repos/majgis/t2-cli/git/commits{/sha}","comments_url":"https://api.github.com/repos/majgis/t2-cli/comments{/number}","issue_comment_url":"https://api.github.com/repos/majgis/t2-cli/issues/comments{/number}","contents_url":"https://api.github.com/repos/majgis/t2-cli/contents/{+path}","compare_url":"https://api.github.com/repos/majgis/t2-cli/compare/{base}...{head}","merges_url":"https://api.github.com/repos/majgis/t2-cli/merges","archive_url":"https://api.github.com/repos/majgis/t2-cli/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/majgis/t2-cli/downloads","issues_url":"https://api.github.com/repos/majgis/t2-cli/issues{/number}","pulls_url":"https://api.github.com/repos/majgis/t2-cli/pulls{/number}","milestones_url":"https://api.github.com/repos/majgis/t2-cli/milestones{/number}","notifications_url":"https://api.github.com/repos/majgis/t2-cli/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/majgis/t2-cli/labels{/name}","releases_url":"https://api.github.com/repos/majgis/t2-cli/releases{/id}","deployments_url":"https://api.github.com/repos/majgis/t2-cli/deployments","created_at":"2016-04-16T16:37:04Z","updated_at":"2016-04-16T16:37:05Z","pushed_at":"2016-06-12T03:50:24Z","git_url":"git://github.com/majgis/t2-cli.git","ssh_url":"git@github.com:majgis/t2-cli.git","clone_url":"https://github.com/majgis/t2-cli.git","svn_url":"https://github.com/majgis/t2-cli","homepage":"","size":1319,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":"tessel:master","ref":"master","sha":"c37ff9df1842ac88d8a921b11e5436e56240ad69","user":{"login":"tessel","id":5573563,"avatar_url":"https://avatars.githubusercontent.com/u/5573563?v=3","gravatar_id":"","url":"https://api.github.com/users/tessel","html_url":"https://github.com/tessel","followers_url":"https://api.github.com/users/tessel/followers","following_url":"https://api.github.com/users/tessel/following{/other_user}","gists_url":"https://api.github.com/users/tessel/gists{/gist_id}","starred_url":"https://api.github.com/users/tessel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tessel/subscriptions","organizations_url":"https://api.github.com/users/tessel/orgs","repos_url":"https://api.github.com/users/tessel/repos","events_url":"https://api.github.com/users/tessel/events{/privacy}","received_events_url":"https://api.github.com/users/tessel/received_events","type":"Organization","site_admin":false},"repo":{"id":30388450,"name":"t2-cli","full_name":"tessel/t2-cli","owner":{"login":"tessel","id":5573563,"avatar_url":"https://avatars.githubusercontent.com/u/5573563?v=3","gravatar_id":"","url":"https://api.github.com/users/tessel","html_url":"https://github.com/tessel","followers_url":"https://api.github.com/users/tessel/followers","following_url":"https://api.github.com/users/tessel/following{/other_user}","gists_url":"https://api.github.com/users/tessel/gists{/gist_id}","starred_url":"https://api.github.com/users/tessel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tessel/subscriptions","organizations_url":"https://api.github.com/users/tessel/orgs","repos_url":"https://api.github.com/users/tessel/repos","events_url":"https://api.github.com/users/tessel/events{/privacy}","received_events_url":"https://api.github.com/users/tessel/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tessel/t2-cli","description":"Command line interface to Tessel 2.","fork":false,"url":"https://api.github.com/repos/tessel/t2-cli","forks_url":"https://api.github.com/repos/tessel/t2-cli/forks","keys_url":"https://api.github.com/repos/tessel/t2-cli/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tessel/t2-cli/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tessel/t2-cli/teams","hooks_url":"https://api.github.com/repos/tessel/t2-cli/hooks","issue_events_url":"https://api.github.com/repos/tessel/t2-cli/issues/events{/number}","events_url":"https://api.github.com/repos/tessel/t2-cli/events","assignees_url":"https://api.github.com/repos/tessel/t2-cli/assignees{/user}","branches_url":"https://api.github.com/repos/tessel/t2-cli/branches{/branch}","tags_url":"https://api.github.com/repos/tessel/t2-cli/tags","blobs_url":"https://api.github.com/repos/tessel/t2-cli/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tessel/t2-cli/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tessel/t2-cli/git/refs{/sha}","trees_url":"https://api.github.com/repos/tessel/t2-cli/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tessel/t2-cli/statuses/{sha}","languages_url":"https://api.github.com/repos/tessel/t2-cli/languages","stargazers_url":"https://api.github.com/repos/tessel/t2-cli/stargazers","contributors_url":"https://api.github.com/repos/tessel/t2-cli/contributors","subscribers_url":"https://api.github.com/repos/tessel/t2-cli/subscribers","subscription_url":"https://api.github.com/repos/tessel/t2-cli/subscription","commits_url":"https://api.github.com/repos/tessel/t2-cli/commits{/sha}","git_commits_url":"https://api.github.com/repos/tessel/t2-cli/git/commits{/sha}","comments_url":"https://api.github.com/repos/tessel/t2-cli/comments{/number}","issue_comment_url":"https://api.github.com/repos/tessel/t2-cli/issues/comments{/number}","contents_url":"https://api.github.com/repos/tessel/t2-cli/contents/{+path}","compare_url":"https://api.github.com/repos/tessel/t2-cli/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tessel/t2-cli/merges","archive_url":"https://api.github.com/repos/tessel/t2-cli/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tessel/t2-cli/downloads","issues_url":"https://api.github.com/repos/tessel/t2-cli/issues{/number}","pulls_url":"https://api.github.com/repos/tessel/t2-cli/pulls{/number}","milestones_url":"https://api.github.com/repos/tessel/t2-cli/milestones{/number}","notifications_url":"https://api.github.com/repos/tessel/t2-cli/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tessel/t2-cli/labels{/name}","releases_url":"https://api.github.com/repos/tessel/t2-cli/releases{/id}","deployments_url":"https://api.github.com/repos/tessel/t2-cli/deployments","created_at":"2015-02-06T01:27:53Z","updated_at":"2016-07-12T05:21:41Z","pushed_at":"2016-07-10T22:02:36Z","git_url":"git://github.com/tessel/t2-cli.git","ssh_url":"git@github.com:tessel/t2-cli.git","clone_url":"https://github.com/tessel/t2-cli.git","svn_url":"https://github.com/tessel/t2-cli","homepage":"","size":1836,"stargazers_count":61,"watchers_count":61,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":34,"mirror_url":null,"open_issues_count":92,"forks":34,"open_issues":92,"watchers":61,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tessel/t2-cli/pulls/744"},"html":{"href":"https://github.com/tessel/t2-cli/pull/744"},"issue":{"href":"https://api.github.com/repos/tessel/t2-cli/issues/744"},"comments":{"href":"https://api.github.com/repos/tessel/t2-cli/issues/744/comments"},"review_comments":{"href":"https://api.github.com/repos/tessel/t2-cli/pulls/744/comments"},"review_comment":{"href":"https://api.github.com/repos/tessel/t2-cli/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tessel/t2-cli/pulls/744/commits"},"statuses":{"href":"https://api.github.com/repos/tessel/t2-cli/statuses/876c169f67199c9f460a84d52feb20164c111e1d"}}}}
{"actor":{"display_login":"HipsterBrown"}}