From 6e067bffd55d66a109be424b5e09019fc412aff3 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Thu, 8 Dec 2016 21:10:46 -0800 Subject: [PATCH] using built-deploy deployment features deploy to drives has been migrated to PXT --- cmds/cmds.ts | 60 ---------------------------------------------- cmds/pxtrequire.ts | 3 +++ 2 files changed, 3 insertions(+), 60 deletions(-) delete mode 100644 cmds/cmds.ts diff --git a/cmds/cmds.ts b/cmds/cmds.ts deleted file mode 100644 index 6e5e1fec..00000000 --- a/cmds/cmds.ts +++ /dev/null @@ -1,60 +0,0 @@ -/// -/// - -import * as fs from "fs"; -import * as path from "path"; -import * as child_process from "child_process"; - -let writeFileAsync: any = Promise.promisify(fs.writeFile) -let execAsync: (cmd: string, options?: { cwd?: string }) => Promise = Promise.promisify(child_process.exec) -let readDirAsync = Promise.promisify(fs.readdir) - - -export function deployCoreAsync(res: ts.pxtc.CompileResult) { - return getBitDrivesAsync() - .then(drives => { - if (drives.length == 0) { - console.log("cannot find any drives to deploy to"); - return Promise.resolve(0); - } - - console.log(`copy ${ts.pxtc.BINARY_HEX} to ` + drives.join(", ")); - - 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 { - if (process.platform == "win32") { - const rx = new RegExp("^([A-Z]:).* " + pxt.appTarget.compile.deployDrives) - return execAsync("wmic PATH Win32_LogicalDisk get DeviceID, VolumeName, FileSystem") - .then(buf => { - let res: string[] = [] - buf.toString("utf8").split(/\n/).forEach(ln => { - let m = rx.exec(ln) - if (m) { - res.push(m[1] + "/") - } - }) - return res - }) - } - else if (process.platform == "darwin") { - const rx = new RegExp(pxt.appTarget.compile.deployDrives) - return readDirAsync("/Volumes") - .then(lst => lst.filter(s => rx.test(s)).map(s => "/Volumes/" + s + "/")) - } else if (process.platform == "linux") { - const rx = new RegExp(pxt.appTarget.compile.deployDrives) - const user = process.env["USER"] - return readDirAsync(`/media/${user}`) - .then(lst => lst.filter(s => rx.test(s)).map(s => `/media/${user}/${s}/`)) - } else { - return Promise.resolve([]) - } -} diff --git a/cmds/pxtrequire.ts b/cmds/pxtrequire.ts index 26442585..227781fb 100644 --- a/cmds/pxtrequire.ts +++ b/cmds/pxtrequire.ts @@ -1,3 +1,6 @@ +/// +/// + import * as path from "path"; export let pxtCore = require("pxt-core"); // require.resolve() gives path to [pxt dir]/built/pxt.js, so move up twice to get pxt root dir