fix(usb): Ignore errors if winusb doesn't load (#1970)

Due to some Windows systems missing certain C runtime libraries
(Visual C/C++ 2012 / 2015 Redistributables), we ignore errors when loading
this module until we can ensure distribution of those along with it.

Change-Type: patch
Changelog-Entry: Fix "The specified module could not be found" on Windows
Fixes #1956
This commit is contained in:
Jonas Hermsmeier 2018-01-18 09:11:46 -08:00 committed by GitHub
parent 8d863638cc
commit 45c72f0c28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -74,6 +74,10 @@ exports.listDevices = () => {
// Include driverless devices into the list of USB devices.
if (process.platform === 'win32') {
// NOTE: Temporarily ignore errors when loading winusb-driver-generator,
// due to C Runtime issues on Windows;
// see https://github.com/resin-io/etcher/issues/1956
try {
const winusbDriverGenerator = require('winusb-driver-generator')
for (const device of winusbDriverGenerator.listDriverlessDevices()) {
devices.push({
@ -84,6 +88,9 @@ exports.listDevices = () => {
}
})
}
} catch (error) {
// Ignore error
}
}
return Bluebird.resolve(devices)