From e8346a52e8416b9238e9fbfe2afb4b32c08c142d Mon Sep 17 00:00:00 2001 From: Denny Pradipta Date: Fri, 29 Nov 2024 09:59:19 +0700 Subject: [PATCH] Fix: Fallback for getOSName --- src/components/notification/alert-message.ts | 21 +++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/components/notification/alert-message.ts b/src/components/notification/alert-message.ts index abb6a14e6..6f47f5610 100644 --- a/src/components/notification/alert-message.ts +++ b/src/components/notification/alert-message.ts @@ -221,14 +221,21 @@ export async function getOSName(): Promise { const isLinux = osPlatform === 'linux' if (isLinux) { - const linuxDistro = await getLinuxDistro() - - // checking again due to inconsistency of getos module return type - if (linuxDistro.os !== 'linux') { - return linuxDistro.os + try { + const linuxDistro = await getLinuxDistro() + + // Checking again due to inconsistency of getos module return type + if (linuxDistro.os !== 'linux') { + return linuxDistro.os + } + + return `${linuxDistro?.dist || 'Unknown Linux Distribution'} - ${ + linuxDistro?.release || 'Unknown Release' + }`.trim() + } catch (error: unknown) { + console.error('Cannot get Linux distribution:', (error as Error).message) + return 'Unknown Linux Distribution - Unknown Release' } - - return `${linuxDistro?.dist} ${linuxDistro?.release}` } return osName()