Deploy no longer throws when no drives found (#269)

pxt deploy no longer throws when no drives found
This commit is contained in:
Guillaume Jenkins 2016-10-17 07:39:29 -07:00 committed by GitHub
parent 5d4bd77bf4
commit 1a3c31c9f3

View File

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