RootMCEvalBot/workers/pkg.js

16 lines
595 B
JavaScript
Raw Permalink Normal View History

2024-01-09 20:15:05 -05:00
const { workerData, parentPort } = require("worker_threads")
const child_process = require("child_process")
child_process.exec(`apt-cache search --names-only '${workerData.pkg}'`, function(err,stdout,stderr) {
if(stdout.trim() == "") {
parentPort.postMessage("NOTFOUND")
} else {
child_process.exec(`sudo apt-get install ${workerData.pkg} -y`, function(err,stdout,stderr) {
if(stderr.trim() == "" || err) {
parentPort.postMessage("ERR")
return;
}
parentPort.postMessage("INSTALLED")
})
}
})