Don't fail to sync without hostnamectl

This commit is contained in:
SamLukeYes 2024-02-14 20:38:23 +08:00
parent 79d8d79b9d
commit 64096de3f8
No known key found for this signature in database
GPG Key ID: 5574FF7A0C9AC292

View File

@ -34,8 +34,11 @@ export const getComputerName = () => {
name = cp.execSync('scutil --get ComputerName').toString().trim()
break
case 'linux':
name = cp.execSync('hostnamectl --pretty').toString().trim()
break
try {
name = cp.execSync('hostnamectl --pretty').toString().trim()
}
// Don't fail even if hostnamectl is unavailable
finally { break }
}
if (!name) name = os.hostname()
return name