mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-01-21 03:55:23 +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 {
|
||||
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;
|
||||
}
|
||||
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user