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; } 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(); }); });