Created
July 26, 2019 10:03
-
-
Save 0x1ad2/d1aeee51131f035b6e9d4ed47907926b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// require utility tools and child_process exec to execute CLI commands | |
const util = require("util"); | |
const exec = util.promisify(require("child_process").exec); | |
// define a async function execute commands | |
async function executeCommands(CommandLineString) { | |
const { stdout, stderr } = await exec(CommandLineString); | |
console.log("Standard output:", stdout); | |
console.log("Standard error:", stderr); | |
} | |
// create command line string | |
function getCommandLIneString(binaries) { | |
return binaries | |
.map(binary => { | |
return `brew cask install ${binary} &&`; | |
}) | |
.join() | |
.replace(/,/g, " ") | |
.slice(0, -3); | |
} | |
// run the prompt and handle the answer | |
multiSelectPrompt | |
.run() | |
.then(binaries => { | |
console.log("Selected binaries:", binaries); | |
console.log("Installing them all"); | |
executeCommands(getCommandLIneString(binaries)); | |
}) | |
.catch(console.error); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment