mirror of
https://github.com/MedzikUser/go-github-selfupdate.git
synced 2024-08-15 03:25:29 +00:00
Merge branch 'fix-tests-windows'
This commit is contained in:
commit
f09afda6e4
2 changed files with 12 additions and 1 deletions
|
@ -7,6 +7,8 @@ import (
|
|||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// UpdateTo download an executable from assetURL and replace the current binary with the downloaded one. cmdPath is a file path to command executable.
|
||||
|
@ -36,6 +38,10 @@ func UpdateTo(assetURL, cmdPath string) error {
|
|||
// UpdateCommand updates a given command binary to the latest version.
|
||||
// 'slug' represents 'owner/name' repository on GitHub and 'current' means the current version.
|
||||
func UpdateCommand(cmdPath string, current semver.Version, slug string) (*Release, error) {
|
||||
if runtime.GOOS == "windows" && !strings.HasSuffix(cmdPath, ".exe") {
|
||||
cmdPath = cmdPath + ".exe"
|
||||
}
|
||||
|
||||
rel, ok, err := DetectLatest(slug)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
@ -16,7 +17,11 @@ func setupTestBinary() {
|
|||
}
|
||||
|
||||
func teardownTestBinary() {
|
||||
if err := os.Remove("github-release-test"); err != nil {
|
||||
bin := "github-release-test"
|
||||
if runtime.GOOS == "windows" {
|
||||
bin = "github-release-test.exe"
|
||||
}
|
||||
if err := os.Remove(bin); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue