From d058f43febe397857ddaa7e72a58310e89576e28 Mon Sep 17 00:00:00 2001 From: "Vipul Gupta (@vipulgupta2048)" Date: Fri, 9 Apr 2021 19:54:04 +0530 Subject: [PATCH 1/2] patch: Fix substring end parameter for accurate CPU ID Signed-off-by: Vipul Gupta (@vipulgupta2048) --- src/lib/system-info.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/system-info.ts b/src/lib/system-info.ts index 5ba9fcaa..7a56282f 100644 --- a/src/lib/system-info.ts +++ b/src/lib/system-info.ts @@ -69,7 +69,7 @@ export async function getCpuId(): Promise { try { const buffer = await fs.readFile('/proc/device-tree/serial-number'); // Remove the null byte at the end - return buffer.toString('utf-8').substr(0, buffer.length - 2); + return buffer.toString('utf-8').replace(/\0/g, ''); } catch { return undefined; } From 50a2f3d313d8883c077aea7e57188b1354942edd Mon Sep 17 00:00:00 2001 From: "Vipul Gupta (@vipulgupta2048)" Date: Tue, 13 Apr 2021 03:19:46 +0530 Subject: [PATCH 2/2] patch: Fix the sysInfo.getCpuId() test Signed-off-by: Vipul Gupta (@vipulgupta2048) --- test/38-sys-info.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/38-sys-info.spec.ts b/test/38-sys-info.spec.ts index 54acc432..156b9c22 100644 --- a/test/38-sys-info.spec.ts +++ b/test/38-sys-info.spec.ts @@ -119,7 +119,7 @@ describe('System information', async () => { ]), ); const cpuId = await sysInfo.getCpuId(); - expect(cpuId).to.equal('1000000001b93f3'); + expect(cpuId).to.equal('1000000001b93f3f'); fsStub.restore(); }); });