Skip to content

Instantly share code, notes, and snippets.

@0x1ad2
Created July 26, 2019 10:03
Show Gist options
  • Save 0x1ad2/d1aeee51131f035b6e9d4ed47907926b to your computer and use it in GitHub Desktop.
Save 0x1ad2/d1aeee51131f035b6e9d4ed47907926b to your computer and use it in GitHub Desktop.
// 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