From 896fa7de9cb031c473cb0bfd43160b1659e9a8eb Mon Sep 17 00:00:00 2001 From: ferhadquluzade Date: Sat, 14 Sep 2024 00:47:07 +0200 Subject: [PATCH] 'ram' flag improvement and minor ones --- bin/index.js | 2 +- bin/subcmd/cpu.js | 7 ------- bin/subcmd/gpu.js | 6 ------ bin/subcmd/ram.js | 21 +++++++++++++++------ 4 files changed, 16 insertions(+), 20 deletions(-) diff --git a/bin/index.js b/bin/index.js index 7953dc2..4373d54 100755 --- a/bin/index.js +++ b/bin/index.js @@ -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": diff --git a/bin/subcmd/cpu.js b/bin/subcmd/cpu.js index ac15a6c..a2adf70 100644 --- a/bin/subcmd/cpu.js +++ b/bin/subcmd/cpu.js @@ -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); }); diff --git a/bin/subcmd/gpu.js b/bin/subcmd/gpu.js index f405967..eb77349 100644 --- a/bin/subcmd/gpu.js +++ b/bin/subcmd/gpu.js @@ -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) => { diff --git a/bin/subcmd/ram.js b/bin/subcmd/ram.js index 9f8cad3..8874eb4 100644 --- a/bin/subcmd/ram.js +++ b/bin/subcmd/ram.js @@ -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; };