Skip to content

Commit

Permalink
usb list command handles missing api device
Browse files Browse the repository at this point in the history
fixes issue where if signed-in to a different account than the connected device
is associated with you get Error: Cannot read property 'platform_id' of null
  • Loading branch information
busticated committed May 5, 2020
1 parent c8c93da commit 16824e6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/cmd/usb.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ module.exports = class UsbCommand {
return Promise.all(info);
})
.then(([device, isInDfuMode, mode]) => {
const { name, platform_id: platformID, connected } = device || {};
const platform = platformsById[usbDevice.platformId];
const type = [platform];

Expand All @@ -62,10 +63,10 @@ module.exports = class UsbCommand {

return {
id: usbDevice.id,
name: (device && device.name) ? device.name : '',
name: name || '',
type: `${type.join(', ')}`,
platform_id: device.platform_id,
connected: device.connected
platform_id: platformID || '',
connected: !!connected
};
})
.finally(() => usbDevice.close());
Expand Down

0 comments on commit 16824e6

Please sign in to comment.