override hid deploy if can hid (#678)

This commit is contained in:
Peli de Halleux 2018-02-26 07:43:02 -08:00 committed by GitHub
parent 81e8f5eeec
commit 08fb679adf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -116,18 +116,21 @@ namespace pxt.editor {
})
}
function initAsync() {
let canHID = false
function canHID(): boolean {
let r = false
if (U.isNodeJS) {
canHID = true
r = true
} else {
const forceHexDownload = /forceHexDownload/i.test(window.location.href);
const isUwp = !!(window as any).Windows;
if (Cloud.isLocalHost() && Cloud.localToken && !forceHexDownload || isUwp)
canHID = true
r = true
}
return r;
}
if (canHID) {
function initAsync() {
if (canHID()) {
return dapAsync();
} else {
return Promise.reject(new Error("no HID"))
@ -401,7 +404,9 @@ namespace pxt.editor {
.then(text => project.overrideTypescriptFile(text))
}]
};
pxt.commands.deployCoreAsync = deployCoreAsync;
if (canHID())
pxt.commands.deployCoreAsync = deployCoreAsync;
return Promise.resolve<pxt.editor.ExtensionResult>(res);
}