Skip to content

Commit

Permalink
Use common err paradigm instead of two args for key generation
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyman727 committed Jun 13, 2015
1 parent ac90f9d commit 01b7d4d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
6 changes: 3 additions & 3 deletions lib/key.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ var provision = require('./tessel/provision'),

module.exports = function() {
return new Promise(function(resolve, reject) {
provision.setupLocal(function(err, created) {
if (!created) {
reject(new Error('Key already exists. No new key created.'));
provision.setupLocal(function(err) {
if (err) {
reject(err);
} else {
resolve();
}
Expand Down
15 changes: 10 additions & 5 deletions lib/tessel/provision.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@ Tessel.prototype.provisionTessel = function() {
var self = this;
if (self.connection.connectionType === 'USB') {
// Check if local .tessel file has keypair, if not, put it there
setupLocal(function() {
// Authorize Tessel for SSH
authTessel(self);
setupLocal(function(err) {
if (err) {
logs.err(err);
return;
} else {
// Authorize Tessel for SSH
authTessel(self);
}
});
} else {
logs.warn('Tessel must be connected with USB to use this command.');
Expand Down Expand Up @@ -75,15 +80,15 @@ function setupLocal(callback) {
return;
} else {
if (typeof callback === 'function') {
callback(null, true);
callback();
}
}
});
});
});
} else {
if (typeof callback === 'function') {
callback(null, false);
callback(new Error('Keys already exist. Refusing to overwrite them.'));
}
}
}
Expand Down

0 comments on commit 01b7d4d

Please sign in to comment.