mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-21 22:47:49 +00:00
Merge pull request #1952 from balena-os/serial-trim
Trim newlines from sysinfo files
This commit is contained in:
commit
c8bef47010
@ -80,8 +80,8 @@ export async function getSystemId(): Promise<string | undefined> {
|
|||||||
fs.readFile('/proc/device-tree/product-sn'),
|
fs.readFile('/proc/device-tree/product-sn'),
|
||||||
fs.readFile('/sys/devices/soc0/serial_number'),
|
fs.readFile('/sys/devices/soc0/serial_number'),
|
||||||
]);
|
]);
|
||||||
// Remove the null byte at the end
|
// Remove the null/newline bytes at the end
|
||||||
return buffer.toString('utf-8').replace(/\0/g, '');
|
return buffer.toString('utf-8').replace(/\0/g, '').trim();
|
||||||
} catch {
|
} catch {
|
||||||
// Otherwise use dmidecode
|
// Otherwise use dmidecode
|
||||||
const [baseBoardInfo] = (
|
const [baseBoardInfo] = (
|
||||||
@ -98,7 +98,7 @@ export async function getSystemModel(): Promise<string | undefined> {
|
|||||||
fs.readFile('/proc/device-tree/product-name'),
|
fs.readFile('/proc/device-tree/product-name'),
|
||||||
]);
|
]);
|
||||||
// Remove the null byte at the end
|
// Remove the null byte at the end
|
||||||
return buffer.toString('utf-8').replace(/\0/g, '');
|
return buffer.toString('utf-8').replace(/\0/g, '').trim();
|
||||||
} catch {
|
} catch {
|
||||||
const [baseBoardInfo] = (
|
const [baseBoardInfo] = (
|
||||||
await dmidecode('baseboard').catch(() => [] as DmiDecodeInfo[])
|
await dmidecode('baseboard').catch(() => [] as DmiDecodeInfo[])
|
||||||
|
Loading…
Reference in New Issue
Block a user