Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
keeramis committed May 14, 2024
1 parent 943284a commit 0c9e0ce
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/cmd/usb.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ module.exports = class UsbCommand extends CLICommandBase {
devices.forEach(device => console.log(device.id));
} else {
if (devices.length === 0) {
console.log(`No devices found.${os.EOL}`);
console.log('No devices found.');
} else {
devices = devices.sort((a, b) => a.name.localeCompare(b.name)); // Sort devices by name

Expand Down Expand Up @@ -237,22 +237,19 @@ module.exports = class UsbCommand extends CLICommandBase {

_forEachUsbDevice(args, func, { dfuMode = false } = {}){
const msg = 'Getting device information...';
let deviceId;
const operation = this._openUsbDevices(args, { dfuMode });
let lastError = null;
return spin(operation, msg)
.then(usbDevices => {
const p = usbDevices.map(usbDevice => {
deviceId = usbDevice.id;
return Promise.resolve()
.then(() => func(usbDevice))
.catch(e => lastError = e)
.finally(() => usbDevice.close());
});
return spin(Promise.all(p), `Sending a command to the device ${deviceId}...`);
return spin(Promise.all(p), `Sending a command to the device...`);
})
.then(() => {
this.stopSpin();
if (lastError){
throw lastError;
}
Expand Down Expand Up @@ -295,6 +292,7 @@ module.exports = class UsbCommand extends CLICommandBase {
});
}

// Helper function to convert CIDR notation to netmask to imitate the 'ifconfig' output
_cidrToNetmask(cidr) {
let mask = [];

Expand Down

0 comments on commit 0c9e0ce

Please sign in to comment.