From bffcc2491fea7043fb3a9b75161c2910e69220f9 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Tue, 6 Feb 2024 16:57:43 +0100 Subject: [PATCH 1/2] feat: Allow to skip version check via `firefox.ignore-version` --- interfacer/src/browsh/config.go | 1 + interfacer/src/browsh/firefox_unix.go | 4 ++++ interfacer/src/browsh/firefox_windows.go | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/interfacer/src/browsh/config.go b/interfacer/src/browsh/config.go index 0ed45839..04c474bd 100644 --- a/interfacer/src/browsh/config.go +++ b/interfacer/src/browsh/config.go @@ -24,6 +24,7 @@ var ( _ = pflag.String("firefox.path", "firefox", "Path to Firefox executable") _ = pflag.Bool("firefox.with-gui", false, "Don't use headless Firefox") _ = pflag.Bool("firefox.use-existing", false, "Whether Browsh should launch Firefox or not") + _ = pflag.Bool("firefox.ignore-version", false, "Whether Browsh should launch Firefox regardless of its version or not") _ = pflag.Bool("monochrome", false, "Start browsh in monochrome mode") _ = pflag.Bool("name", false, "Print out the name: Browsh") ) diff --git a/interfacer/src/browsh/firefox_unix.go b/interfacer/src/browsh/firefox_unix.go index 57f6ea6d..b7d19996 100644 --- a/interfacer/src/browsh/firefox_unix.go +++ b/interfacer/src/browsh/firefox_unix.go @@ -6,6 +6,7 @@ import ( "strings" "github.com/go-errors/errors" + "github.com/spf13/viper" ) func getFirefoxPath() string { @@ -13,6 +14,9 @@ func getFirefoxPath() string { } func ensureFirefoxVersion(path string) { + if viper.GetBool("firefox.ignore-version") { + return + } output := Shell(path + " --version") pieces := strings.Split(output, " ") version := pieces[len(pieces)-1] diff --git a/interfacer/src/browsh/firefox_windows.go b/interfacer/src/browsh/firefox_windows.go index 7bb1c08b..f806e1bd 100644 --- a/interfacer/src/browsh/firefox_windows.go +++ b/interfacer/src/browsh/firefox_windows.go @@ -8,6 +8,7 @@ import ( "strings" "github.com/go-errors/errors" + "github.com/spf13/viper" "golang.org/x/sys/windows/registry" ) @@ -97,6 +98,9 @@ func getFirefoxFlavor() string { } func ensureFirefoxVersion(path string) { + if viper.GetBool("firefox.ignore-version") { + return + } versionString := getWindowsFirefoxVersionString() pieces := strings.Split(versionString, " ") version := pieces[0] From a16fa7643afc9a73352b314a4e3906a1c14281fb Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Tue, 6 Feb 2024 17:19:22 +0100 Subject: [PATCH 2/2] style: Swap spaces to tabs in `ignore-version` implementation --- interfacer/src/browsh/firefox_unix.go | 4 ++-- interfacer/src/browsh/firefox_windows.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/interfacer/src/browsh/firefox_unix.go b/interfacer/src/browsh/firefox_unix.go index b7d19996..8aff1284 100644 --- a/interfacer/src/browsh/firefox_unix.go +++ b/interfacer/src/browsh/firefox_unix.go @@ -15,8 +15,8 @@ func getFirefoxPath() string { func ensureFirefoxVersion(path string) { if viper.GetBool("firefox.ignore-version") { - return - } + return + } output := Shell(path + " --version") pieces := strings.Split(output, " ") version := pieces[len(pieces)-1] diff --git a/interfacer/src/browsh/firefox_windows.go b/interfacer/src/browsh/firefox_windows.go index f806e1bd..b76df74d 100644 --- a/interfacer/src/browsh/firefox_windows.go +++ b/interfacer/src/browsh/firefox_windows.go @@ -99,8 +99,8 @@ func getFirefoxFlavor() string { func ensureFirefoxVersion(path string) { if viper.GetBool("firefox.ignore-version") { - return - } + return + } versionString := getWindowsFirefoxVersionString() pieces := strings.Split(versionString, " ") version := pieces[0]