Skip to content

Instantly share code, notes, and snippets.

@eduardogspereira
Created December 28, 2019 02:12
Show Gist options
  • Save eduardogspereira/6b279839cec455d62dc97f920765b3e0 to your computer and use it in GitHub Desktop.
Save eduardogspereira/6b279839cec455d62dc97f920765b3e0 to your computer and use it in GitHub Desktop.
const { execSync } = require("child_process");
const readline = require("readline").createInterface({
input: process.stdin,
output: process.stdout
});
const rawData = execSync("pacman -Q");
const programs = rawData
.toString()
.split("\n")
.filter(v => v !== "")
.map(v => v.split(" ")[0]);
const shouldDelete = readline =>
new Promise(resolve => readline.question("", resolve));
const main = async () => {
for (const program of programs) {
console.log("#####====#####");
console.log(program);
console.log("#####====#####");
try {
execSync(`pacman -Rns ${program} & sleep 0 && exit`, {
stdio: [0, 1, 2]
});
} catch (e) {}
if ((await shouldDelete(readline)) == "y") {
execSync(`pacman -Rns ${program} --noconfirm`, {
stdio: [0, 1, 2]
});
}
}
readline.close();
};
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment