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