diff --git a/lib/inquire.js b/lib/inquire.js index 7695629..55b51ba 100644 --- a/lib/inquire.js +++ b/lib/inquire.js @@ -10,14 +10,11 @@ const Inquire = function(cb) { this.callback = cb; - this.interchange.get_ports((err, ports) => { - if (err) { - console.error(err); - return; - } - - this.promptQuestions(ports); - }); + this.interchange.get_ports() + .then(ports => { + this.promptQuestions(ports); + }) + .catch(err => console.error(err)); }; Inquire.prototype.promptQuestions = function(ports) { diff --git a/lib/interchange.js b/lib/interchange.js index e5e9c1c..8d9ce12 100644 --- a/lib/interchange.js +++ b/lib/interchange.js @@ -44,39 +44,26 @@ Interchange.prototype.list_devices = function() { }); }); - return ({firmwares: fws}); + return (fws); }; Interchange.prototype.get_ports = function(cb) { - Serialport.list() - .then(function(ports) { - if (cb) return cb(null, ports); - }) - .catch((err) => { - if (cb) return cb(err); - }); + return new Promise((resolve, reject) => { + Serialport.list() + .then((ports) => { + resolve(ports); + }) + .catch((err) => { + reject(err); + }); + }); }; -Interchange.prototype.list_ports = function(opts) { +Interchange.prototype.list_ports = function() { // this function lists out all the ports available to flash firmware - - const verbose = opts.verbose; - - this.get_ports(function(err, ports) { - if (err) { - console.error(err); - return; - } - - if (verbose) { - console.info(ports); - } else { - ports.forEach(function(port) { - console.info(port.comName.cyan); - console.info(port.manufacturer); - }); - } - }); + // this function is now deprecated + console.warn('list_ports method deprecated - use get_ports instead'); + return this.get_ports(); }; Interchange.prototype.get_firmware_info = function(port) {