Skip to content

Commit

Permalink
Travis lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelmota committed Nov 15, 2020
1 parent 0859a6c commit 0acb49c
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 54 deletions.
4 changes: 2 additions & 2 deletions cointop/common/open/open.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ func init() {
}

// URL open url
func URL(s string) error {
func URL(url string) error {
if openCmd != "" {
exec.Command(openCmd, s).Output()
return exec.Command(openCmd, url).Run()
}
return nil
}
Expand Down
52 changes: 0 additions & 52 deletions cointop/common/open/open_win.go

This file was deleted.

50 changes: 50 additions & 0 deletions cointop/common/open/open_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package open

import (
"os/exec"
)

var windowsOpenCmd string
var windowsPossibleCmds = []string{
"Start-Process",
}
var windowsPossibleExecs = []string{
"powershell.exe",
"explorer.exe",
}
var windowsOpenExec string

func init() {
for _, exe := range windowsPossibleExecs {
execPath, err := exec.LookPath(exe)
if err != nil {
continue
}

windowsOpenExec = execPath
break
}

for _, cmd := range windowsPossibleCmds {
err := exec.Command(windowsOpenExec, "Get-Command", cmd).Run()
if err != nil {
continue
}

windowsOpenCmd = cmd
break
}
}

// URL open url
func URL(url string) error {
if windowsOpenCmd != "" {
return exec.Command(windowsOpenExec, windowsOpenCmd, url).Run()
}
return nil
}

// CommandExists returns true if an 'open' command exists
func CommandExists() bool {
return windowsOpenCmd != ""
}

0 comments on commit 0acb49c

Please sign in to comment.