-
Notifications
You must be signed in to change notification settings - Fork 10
Refactor getBrowserNameByOS #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,9 +32,11 @@ const ( | |
| ) | ||
|
|
||
| // Colors for console output | ||
| var blue = color.New(color.FgBlue, color.Bold).SprintFunc() | ||
| var yellow = color.New(color.FgYellow, color.Bold).SprintFunc() | ||
| var red = color.New(color.FgRed, color.Bold).SprintFunc() | ||
| var ( | ||
| blue = color.New(color.FgBlue, color.Bold).SprintFunc() | ||
| yellow = color.New(color.FgYellow, color.Bold).SprintFunc() | ||
| red = color.New(color.FgRed, color.Bold).SprintFunc() | ||
| ) | ||
|
|
||
| type logWriter struct{} | ||
|
|
||
|
|
@@ -223,27 +225,26 @@ func findBrowser(target string) string { | |
| } | ||
|
|
||
| // getBrowserNameByOS normilizes browser name | ||
| func getBrowserNameByOS(k string) string { | ||
| browser := "" | ||
| switch k { | ||
| case "google", "chrome": | ||
| switch runtime.GOOS { | ||
| case "darwin": | ||
| browser = "Google Chrome" | ||
| } | ||
| case "mozilla", "firefox": | ||
| switch runtime.GOOS { | ||
| case "darwin": | ||
| browser = "Firefox" | ||
| } | ||
| case "brave": | ||
| switch runtime.GOOS { | ||
| case "darwin": | ||
| browser = "Brave" | ||
| func getBrowserNameByOS(denormalizedStr string) string { | ||
| os := runtime.GOOS | ||
|
|
||
| // key = denormalized value, value = normalized value | ||
| browserNameMap := map[string]string{ | ||
| "google": "Google Chrome", | ||
| "chrome": "Google Chrome", | ||
| "mozilla": "Firefox", | ||
| "firefox": "Firefox", | ||
| "brave": "Brave", | ||
| } | ||
|
|
||
| if os == "darwin" { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking if we can refactor this to support Windows and Linux.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That sounds good - would the denormalized values be anything different?
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I add this issue. there is a list of all the OS name. the browser string may be vary between each OS. |
||
| normalizedStr, ok := browserNameMap[denormalizedStr] | ||
| if ok { | ||
| return normalizedStr | ||
| } | ||
| } | ||
|
|
||
| return browser | ||
| return "" | ||
| } | ||
|
|
||
| // checkGoPath checks for GOPATH | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section is mainly for the dependencies I use on the project. Your name will show up in the release. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, definitely. I'll add a credit to stretchr maybe?