Reject promise when deploy to board fails (#267)

* Reject promise when deploy to board fails

* Change var to let
This commit is contained in:
Guillaume Jenkins 2016-10-03 15:26:41 -07:00 committed by Peli de Halleux
parent a34f765681
commit 5e9eec61c5
1 changed files with 6 additions and 3 deletions

View File

@ -13,10 +13,13 @@ export function deployCoreAsync(res: ts.pxtc.CompileResult) {
return getBitDrivesAsync()
.then(drives => {
if (drives.length == 0) {
console.log("cannot find any drives to deploy to")
} else {
console.log(`copy ${ts.pxtc.BINARY_HEX} to ` + drives.join(", "))
let msg = "cannot find any drives to deploy to";
console.log(msg);
return Promise.reject(new Error(msg));
}
console.log(`copy ${ts.pxtc.BINARY_HEX} to ` + drives.join(", "))
return Promise.map(drives, d =>
writeFileAsync(d + ts.pxtc.BINARY_HEX, res.outfiles[ts.pxtc.BINARY_HEX])
.then(() => {