From 1a3c31c9f347f312f9117e3b1540cb74296d3600 Mon Sep 17 00:00:00 2001 From: Guillaume Jenkins Date: Mon, 17 Oct 2016 07:39:29 -0700 Subject: [PATCH] Deploy no longer throws when no drives found (#269) pxt deploy no longer throws when no drives found --- cmds/cmds.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/cmds/cmds.ts b/cmds/cmds.ts index c862c7a6..be21defb 100644 --- a/cmds/cmds.ts +++ b/cmds/cmds.ts @@ -13,20 +13,20 @@ export function deployCoreAsync(res: ts.pxtc.CompileResult) { return getBitDrivesAsync() .then(drives => { if (drives.length == 0) { - let msg = "cannot find any drives to deploy to"; - console.log(msg); - return Promise.reject(new Error(msg)); + console.log("cannot find any drives to deploy to"); + return Promise.resolve(0); } - 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 => - writeFileAsync(d + ts.pxtc.BINARY_HEX, res.outfiles[ts.pxtc.BINARY_HEX]) - .then(() => { - console.log("wrote hex file to " + d) - })) - }) - .then(() => { }) + let writeHexFile = (filename: string) => { + return writeFileAsync(filename + ts.pxtc.BINARY_HEX, res.outfiles[ts.pxtc.BINARY_HEX]) + .then(() => console.log("wrote hex file to " + filename)); + }; + + return Promise.map(drives, d => writeHexFile(d)) + .then(() => drives.length); + }); } function getBitDrivesAsync(): Promise {