Created
December 28, 2019 02:12
-
-
Save eduardogspereira/6b279839cec455d62dc97f920765b3e0 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
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