From 07128efe80d8d371a3d9c24efac94952c9f772d5 Mon Sep 17 00:00:00 2001 From: yandeu <20306025+yandeu@users.noreply.github.com> Date: Tue, 3 Dec 2024 13:53:45 +0100 Subject: [PATCH] Update openBrowser.ts --- src/openBrowser.ts | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/openBrowser.ts b/src/openBrowser.ts index e6e0a26..ea6c026 100644 --- a/src/openBrowser.ts +++ b/src/openBrowser.ts @@ -65,23 +65,33 @@ export class OpenBrowser { res = await this.open(target, browser[index]) } + const is_undefined_str = browser => typeof browser === 'string' && browser === 'undefined' + if (!res) { if (typeof browser === 'string') { if (browser === 'default') { message.log(colors(`Could not open the default browser. Will abort!`, 'red')) return } else { - message.log(colors(`Could not open browser "${browser}". Trying the default browser next.`, 'yellow')) + if (!is_undefined_str(browser)) { + message.log(colors(`Could not open browser "${browser}". Trying the default browser next.`, 'yellow')) + } await this.launchDefaultBrowser(target) } } else if (Array.isArray(browser)) { if (typeof browser[index + 1] === 'undefined') { - message.log(colors(`Could not open browser "${browser[index]}". Trying the default browser next.`, 'yellow')) + if (!is_undefined_str(browser[index])) { + message.log( + colors(`Could not open browser "${browser[index]}". Trying the default browser next.`, 'yellow') + ) + } await this.launchDefaultBrowser(target) } else { - message.log( - colors(`Could not open browser "${browser[index]}". Trying "${browser[index + 1]}" next.`, 'yellow') - ) + if (!is_undefined_str(browser[index])) { + message.log( + colors(`Could not open browser "${browser[index]}". Trying "${browser[index + 1]}" next.`, 'yellow') + ) + } await this.launchBrowser(target, browser, index) } }