mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-02-01 08:47:56 +00:00
Merge pull request #1655 from balena-os/vipul/fix-getcpuid
patch: Fix substring end parameter to get accurate CPU ID
This commit is contained in:
commit
192589d19e
@ -69,7 +69,7 @@ export async function getCpuId(): Promise<string | undefined> {
|
|||||||
try {
|
try {
|
||||||
const buffer = await fs.readFile('/proc/device-tree/serial-number');
|
const buffer = await fs.readFile('/proc/device-tree/serial-number');
|
||||||
// Remove the null byte at the end
|
// 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 {
|
} catch {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ describe('System information', async () => {
|
|||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
const cpuId = await sysInfo.getCpuId();
|
const cpuId = await sysInfo.getCpuId();
|
||||||
expect(cpuId).to.equal('1000000001b93f3');
|
expect(cpuId).to.equal('1000000001b93f3f');
|
||||||
fsStub.restore();
|
fsStub.restore();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user