Skip to content

Commit

Permalink
'ram' flag improvement and minor ones
Browse files Browse the repository at this point in the history
  • Loading branch information
ferhadquluzade committed Sep 13, 2024
1 parent 35276c1 commit 896fa7d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 20 deletions.
2 changes: 1 addition & 1 deletion bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async function main() {
console.log(envInfo);
break;
case "--ram":
const ramInfo = getRamInfo();
const ramInfo = await getRamInfo();
console.log(ramInfo);
break;
case "--cpu":
Expand Down
7 changes: 0 additions & 7 deletions bin/subcmd/cpu.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@ export const getCpuInfo = () => {
let result = `architecture: ${os.arch()}
cpus: ${cpus.length}`;

if (cpus.length === 1)
return (
result +
`\nmodel: ${cpus[0].model}
speed: ${cpus[0].speed} MHz`
);

cpus.forEach((cpu, index) => {
result += processedResult(cpu, index);
});
Expand Down
6 changes: 0 additions & 6 deletions bin/subcmd/gpu.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ import si from "systeminformation";

export const getGpuInfo = async () => {
const gpus = (await si.graphics()).displays;
if (gpus.length === 1)
return `vendor: ${gpus[0].vendor}
model: ${gpus[0].model}
resolutionX: ${gpus[0].resolutionX}
resolutionY: ${gpus[0].resolutionY}
refreshRate: ${gpus[0].currentRefreshRate}`;

let result = `gpus:${gpus.length}`;
gpus.forEach((gpu, index) => {
Expand Down
21 changes: 15 additions & 6 deletions bin/subcmd/ram.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
import os from "os";
import { formatBytes } from "../formatter/bytes.js";
import si from "systeminformation";

export const getRamInfo = () => {
export const getRamInfo = async () => {
const totalMemory = os.totalmem();
const freeMemory = os.freemem();
const usedMemory = totalMemory - freeMemory;

return {
totalMemory: formatBytes(totalMemory),
freeMemory: formatBytes(freeMemory),
usedMemory: formatBytes(usedMemory),
};
const rams = await si.memLayout();
let result = `total: ${formatBytes(totalMemory)},
free: ${formatBytes(freeMemory)},
used: ${formatBytes(usedMemory)},
rams: ${rams.length}`;

rams.forEach((ram, index) => {
result += `\nram#${index + 1}
\tvendor: ${ram.manufacturer}
\ttype: ${ram.type}`;
});

return result;
};

0 comments on commit 896fa7d

Please sign in to comment.