Skip to content

Commit

Permalink
feat: support install package on window git-bash
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoxiaojie committed Dec 24, 2024
1 parent de7232b commit e68e299
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/coverage-report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.19.x
go-version: 1.23
- uses: actions/checkout@v3.6.0
- name: Test
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: 1.23
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v3.6.0
Expand Down Expand Up @@ -56,7 +56,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: 1.23
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v3.6.0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: 1.23
- name: Image Registry Login
run: |
docker login --username ${{ secrets.DOCKER_HUB_USER }} --password ${{secrets.DOCKER_HUB_TOKEN}}
Expand Down
2 changes: 1 addition & 1 deletion cmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func newDownloadOption(ctx context.Context) *downloadOption {
RoundTripper: getRoundTripper(ctx),
fetcher: &installer.DefaultFetcher{},
wait: &sync.WaitGroup{},
execer: fakeruntime.DefaultExecer{},
execer: fakeruntime.NewDefaultExecer(),
}
}

Expand Down
5 changes: 4 additions & 1 deletion cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
func newInstallCmd(ctx context.Context) (cmd *cobra.Command) {
opt := &installOption{
downloadOption: newDownloadOption(ctx),
execer: &fakeruntime.DefaultExecer{},
execer: fakeruntime.NewDefaultExecer(),
}
cmd = &cobra.Command{
Use: "install",
Expand Down Expand Up @@ -70,6 +70,9 @@ func (o *installOption) getDefaultInstallDir() string {
case "linux", "darwin":
return "/usr/local/bin"
case "windows":
if o.execer.Getenv("SHELL") == "/usr/bin/bash" {
return "/usr/bin"
}
return `C:\Program Files (x86)\Common Files`
}
return ""
Expand Down
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/linuxsuren/http-downloader

go 1.19
go 1.23

require (
github.com/AlecAivazis/survey/v2 v2.3.2
Expand All @@ -25,7 +25,7 @@ require (
github.com/antonmedv/expr v1.11.1
github.com/creack/pty v1.1.17
github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213
github.com/linuxsuren/go-fake-runtime v0.0.0-20230426144714-1a7a0d160d3f
github.com/linuxsuren/go-fake-runtime v0.0.5
github.com/schollz/progressbar/v3 v3.13.0
)

Expand All @@ -38,7 +38,6 @@ require (
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/prometheus/client_golang v1.11.1 // indirect
github.com/rivo/uniseg v0.4.3 // indirect
github.com/skeema/knownhosts v1.2.1 // indirect
golang.org/x/mod v0.12.0 // indirect
Expand Down
49 changes: 14 additions & 35 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/installer/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const (
// CheckDepAndInstall checks the desired tools, install the missing packages
func (o *Installer) CheckDepAndInstall(tools map[string]string) (err error) {
if o.Execer == nil {
o.Execer = &fakeruntime.DefaultExecer{}
o.Execer = fakeruntime.NewDefaultExecer()
}
if o.OS == "" {
o.OS = o.Execer.OS()
Expand Down
1 change: 1 addition & 0 deletions pkg/net/test.log
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fake body
2 changes: 1 addition & 1 deletion pkg/os/generic_installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func parseGenericPackages(configFile string, genericPackages *genericPackages) (

// GenericInstallerRegistry registries a generic installer
func GenericInstallerRegistry(configFile string, registry core.InstallerRegistry) (err error) {
defaultExecer := fakeruntime.DefaultExecer{}
defaultExecer := fakeruntime.NewDefaultExecer()
genericPackages := &genericPackages{}
if err = parseGenericPackages(configFile, genericPackages); err != nil {
return
Expand Down
2 changes: 1 addition & 1 deletion pkg/os/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type DefaultInstallerRegistry struct {
var defaultInstallerRegistry *DefaultInstallerRegistry

func init() {
defaultExecer := fakeruntime.DefaultExecer{}
defaultExecer := fakeruntime.NewDefaultExecer()
defaultInstallerRegistry = &DefaultInstallerRegistry{
installerMap: map[string][]core.Installer{},
}
Expand Down

0 comments on commit e68e299

Please sign in to comment.