{"action":"created","comment":{"url":"https://api.github.com/repos/tessel/t2-cli/pulls/comments/27340921","id":27340921,"diff_hunk":"@@ -38,80 +40,71 @@ LANConnection.prototype.end = function() {\n }\n \n LANConnection.prototype.open = function(callback) {\n-  // Create a new SSH client connection object\n-  this.ssh = new Client()\n-  // Open up an SSH Connection\n-  this.ssh.on('ready', function() {\n-    callback && callback(null);\n+  var self = this;\n+  return new Promise(function(resolve, reject) {\n+    // Create a new SSH client connection object\n+    self.ssh = new Client()\n+    // Open up an SSH Connection\n+    self.ssh.on('ready', function() {\n+      // Tessel allows connection\n+      self.authorized = true;\n+      // Resolve with connection\n+      resolve(self);\n+    });\n+    self.ssh.on('error', function(err) {\n+      // Reject with error\n+      reject(err);\n+    }).connect(self.auth);\n   });\n-  this.ssh.on('error', function(err) {\n-    callback && callback(err);\n-  }).connect(this.auth);\n }\n \n // Find all LAN connected Tessels\n-function findConnections(callback) {\n-\n+function findConnections() {\n+  var lanConfig, envConfig;\n   // Grab all mDNS connected Tessels\n-  findmDNSConnections(function(err, connections) {\n-    // Riase any errors\n-    if (err) {\n-      return callback && callback(err);\n-    }\n-\n-    // Check if a config file exists\n-    fs.exists(__dirname + '/../config.env', function (exists) {\n-      // If it does\n-      if (exists) {\n-        // parse it\n-        config = envfile.parseFileSync(__dirname + '/../config.env')\n-        // Create a LAN Connection with the provided auth credentials\n-        var conn = new LANConnection({\n-          host: config.host,\n-          username: 'root',\n-          port: 22,\n-          privateKey: fs.readFileSync(config.keyPath),\n-          passphrase: config.keyPassphrase\n+  return findmDNSConnections()\n+    // TODO: Remove this step once Tessel Setup is built\n+    .then(function(tessels){\n+      return new Promise(function(resolve, reject) {\n+        // Check if a config file exists\n+        fs.exists(__dirname + '/../config.env', function (exists) {\n+          // If it does\n+          if (exists) {\n+            // parse it\n+            envConfig = envfile.parseFileSync(__dirname + '/../config.env')\n+            // Create a LAN Config with the provided auth credentials\n+            lanConfig = {\n+              host: envConfig.host,\n+              username: 'root',\n+              port: 22,\n+              privateKey: fs.readFileSync(envConfig.keyPath),\n+              passphrase: envConfig.keyPassphrase\n+            }\n+          } else {\n+            return reject('Set up your config.env with keyPath and keyPassphrase');\n+          }\n+          // Pass the tessel's through or else you have no tessels\n+          return resolve(tessels);\n         });\n-\n-        // Insert the specified connection as the first item\n-        // so that it will be preferred\n-        connections.unshift(conn);\n-      }\n-\n-      // Open the connections and return them\n-      return openConnections(connections, callback);\n-    });\n-  });\n-\n-  // For each LAN Conenction, try to open up an SSH session\n-  // Should we really be doing this here?\n-  function openConnections(connections, callback) {\n-    async.each(connections, function(conn, cb) {\n-      conn.open(function(err) {\n-        conn.initError = err;\n-        cb(err);\n       });\n-    }, function(err) {\n-      callback(err, connections)\n-    });\n-  }\n+    })\n+    // Create new LAN connections for each tessel.\n+    .map(function(tessel){","path":"lib/lan_connection.js","position":122,"original_position":122,"commit_id":"62e6d33db8c8051db1ccdcee3525455db917f882","original_commit_id":"62e6d33db8c8051db1ccdcee3525455db917f882","user":{"login":"HarleyKwyn","id":5528612,"avatar_url":"https://avatars.githubusercontent.com/u/5528612?v=3","gravatar_id":"","url":"https://api.github.com/users/HarleyKwyn","html_url":"https://github.com/HarleyKwyn","followers_url":"https://api.github.com/users/HarleyKwyn/followers","following_url":"https://api.github.com/users/HarleyKwyn/following{/other_user}","gists_url":"https://api.github.com/users/HarleyKwyn/gists{/gist_id}","starred_url":"https://api.github.com/users/HarleyKwyn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HarleyKwyn/subscriptions","organizations_url":"https://api.github.com/users/HarleyKwyn/orgs","repos_url":"https://api.github.com/users/HarleyKwyn/repos","events_url":"https://api.github.com/users/HarleyKwyn/events{/privacy}","received_events_url":"https://api.github.com/users/HarleyKwyn/received_events","type":"User","site_admin":false},"body":"Will in the future impliment this to be controlled by flags.","created_at":"2015-03-28T01:15:05Z","updated_at":"2015-03-28T01:15:05Z","html_url":"https://github.com/tessel/t2-cli/pull/48#discussion_r27340921","pull_request_url":"https://api.github.com/repos/tessel/t2-cli/pulls/48","_links":{"self":{"href":"https://api.github.com/repos/tessel/t2-cli/pulls/comments/27340921"},"html":{"href":"https://github.com/tessel/t2-cli/pull/48#discussion_r27340921"},"pull_request":{"href":"https://api.github.com/repos/tessel/t2-cli/pulls/48"}}},"pull_request":{"url":"https://api.github.com/repos/tessel/t2-cli/pulls/48","id":32151011,"html_url":"https://github.com/tessel/t2-cli/pull/48","diff_url":"https://github.com/tessel/t2-cli/pull/48.diff","patch_url":"https://github.com/tessel/t2-cli/pull/48.patch","issue_url":"https://api.github.com/repos/tessel/t2-cli/issues/48","number":48,"state":"open","locked":false,"title":"Promises, promises everywhere","user":{"login":"HarleyKwyn","id":5528612,"avatar_url":"https://avatars.githubusercontent.com/u/5528612?v=3","gravatar_id":"","url":"https://api.github.com/users/HarleyKwyn","html_url":"https://github.com/HarleyKwyn","followers_url":"https://api.github.com/users/HarleyKwyn/followers","following_url":"https://api.github.com/users/HarleyKwyn/following{/other_user}","gists_url":"https://api.github.com/users/HarleyKwyn/gists{/gist_id}","starred_url":"https://api.github.com/users/HarleyKwyn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HarleyKwyn/subscriptions","organizations_url":"https://api.github.com/users/HarleyKwyn/orgs","repos_url":"https://api.github.com/users/HarleyKwyn/repos","events_url":"https://api.github.com/users/HarleyKwyn/events{/privacy}","received_events_url":"https://api.github.com/users/HarleyKwyn/received_events","type":"User","site_admin":false},"body":"Let's hope they deliver :package:  :P ","created_at":"2015-03-27T22:39:15Z","updated_at":"2015-03-28T01:15:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fcb8487b8870f97acbcecf7781ea04363a2dc8e8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/tessel/t2-cli/pulls/48/commits","review_comments_url":"https://api.github.com/repos/tessel/t2-cli/pulls/48/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/48/comments","statuses_url":"https://api.github.com/repos/tessel/t2-cli/statuses/62e6d33db8c8051db1ccdcee3525455db917f882","head":{"label":"tessel:km-tessel-list","ref":"km-tessel-list","sha":"62e6d33db8c8051db1ccdcee3525455db917f882","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}","created_at":"2015-02-06T01:27:53Z","updated_at":"2015-03-27T00:33:26Z","pushed_at":"2015-03-28T01:00:41Z","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":858,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":10,"forks":0,"open_issues":10,"watchers":2,"default_branch":"master"}},"base":{"label":"tessel:master","ref":"master","sha":"256c50f48e59575fadeabd7f328f15563d169112","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}","created_at":"2015-02-06T01:27:53Z","updated_at":"2015-03-27T00:33:26Z","pushed_at":"2015-03-28T01:00:41Z","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":858,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":10,"forks":0,"open_issues":10,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tessel/t2-cli/pulls/48"},"html":{"href":"https://github.com/tessel/t2-cli/pull/48"},"issue":{"href":"https://api.github.com/repos/tessel/t2-cli/issues/48"},"comments":{"href":"https://api.github.com/repos/tessel/t2-cli/issues/48/comments"},"review_comments":{"href":"https://api.github.com/repos/tessel/t2-cli/pulls/48/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/48/commits"},"statuses":{"href":"https://api.github.com/repos/tessel/t2-cli/statuses/62e6d33db8c8051db1ccdcee3525455db917f882"}}}}