From 22faf4f6e49bac25affb6df5489f8e6e2aaa2123 Mon Sep 17 00:00:00 2001 From: dimaslanjaka Date: Thu, 4 May 2023 05:36:08 +0700 Subject: [PATCH] fix(ts): error TS2322 Type 'string | void | Buffer' is not assignable to type 'string'. Type 'void' is not assignable to type 'string'. --- lib/console/version.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/console/version.ts b/lib/console/version.ts index 0a989da8..0333b703 100644 --- a/lib/console/version.ts +++ b/lib/console/version.ts @@ -13,12 +13,12 @@ async function versionConsole() { console.log('hexo-cli:', pkg.version); - let osInfo = ''; + let osInfo: string | void | Buffer; if (platform === 'darwin') osInfo = await spawn('sw_vers', '-productVersion'); else if (platform === 'linux') { const v = await spawn('cat', '/etc/os-release'); - const distro = (v || '').match(/NAME="(.+)"/); - const versionInfo = (v || '').match(/VERSION="(.+)"/) || ['', '']; + const distro = String(v || '').match(/NAME="(.+)"/); + const versionInfo = String(v || '').match(/VERSION="(.+)"/) || ['', '']; const versionStr = versionInfo !== null ? versionInfo[1] : ''; osInfo = `${distro[1]} ${versionStr}`.trim() || ''; }