thaw-carrots/index.js

41 lines
947 B
JavaScript
Raw Normal View History

const si = require("systeminformation");
2018-10-11 06:19:42 +00:00
const mri = require("mri");
const sll = require("single-line-log").stdout;
const kleur = require("kleur");
2018-10-11 06:52:54 +00:00
const isPrime = require("prime-number");
const eatCPU = require("./eat-cpu");
async function readTemp() {
const temp = await si.cpuTemperature();
return { main: temp.main, cores: temp.cores };
}
2018-10-11 06:19:42 +00:00
async function thawMyCarrots(targetTemp) {
2018-10-11 06:52:54 +00:00
let temp = await readTemp(),
n = 2;
while (1) {
if (temp.main < targetTemp) {
eatCPU(n);
n = n + 1;
}
temp = await readTemp();
2018-10-11 06:52:54 +00:00
sll(
"Current temp",
kleur.bold.red(temp.main.toFixed(2)),
"\nCores at",
kleur.bold.gray(temp.cores),
n
);
}
}
2018-10-11 06:19:42 +00:00
const args = process.argv.slice(2),
targetTemp = mri(args, {
alias: { temp: "t" },
default: { temp: 85 }
});
thawMyCarrots(targetTemp.temp);