Fix hid deployment from command line

This commit is contained in:
Michal Moskal 2017-08-08 11:47:10 +02:00
parent d42117a2a5
commit ebcde71950

View File

@ -28,19 +28,33 @@ namespace pxt.editor {
let initPromise: Promise<Ev3Wrapper> let initPromise: Promise<Ev3Wrapper>
function initAsync() { function initAsync() {
const forceHexDownload = /forceHexDownload/i.test(window.location.href); if (initPromise)
if (Cloud.isLocalHost() && Cloud.localToken && !forceHexDownload) { return initPromise
if (!initPromise)
initPromise = hf2Async() let canHID = false
.catch(err => { if (U.isNodeJS) {
initPromise = null canHID = true
noHID = true } else {
return Promise.reject(err) const forceHexDownload = /forceHexDownload/i.test(window.location.href);
}) if (Cloud.isLocalHost() && Cloud.localToken && !forceHexDownload)
canHID = true
}
if (noHID)
canHID = false
if (canHID) {
initPromise = hf2Async()
.catch(err => {
initPromise = null
noHID = true
return Promise.reject(err)
})
} else { } else {
noHID = true noHID = true
initPromise = Promise.reject(new Error("no HID")) initPromise = Promise.reject(new Error("no HID"))
} }
return initPromise return initPromise
} }