Skip to content

Commit

Permalink
throw no devices found in case usb devices is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
hugomontero committed Oct 17, 2023
1 parent 63412b2 commit 8d419d0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/cmd/usb-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ async function getOneUsbDevice({ idOrName, api, auth, ui, flashMode, platformId
}

const usbDevices = await getUsbDevices({ dfuMode: true });
if (!usbDevices.length) {
throw new Error('No devices found');
}
let devices = await Promise.all(usbDevices.map(async (d) => {
const { id, mode } = await _getDeviceInfo(d);
const name = await _getDeviceName({ id, api, auth, ui });
Expand Down Expand Up @@ -227,7 +230,7 @@ async function getOneUsbDevice({ idOrName, api, auth, ui, flashMode, platformId
} else if (!devices.length) {
if (flashMode === 'DFU') {
ui.logDFUModeRequired();
} else {
} else if (flashMode === 'NORMAL') {
ui.logNormalModeRequired();
}
throw new Error('No devices found');
Expand Down

0 comments on commit 8d419d0

Please sign in to comment.