Skip to content

Commit

Permalink
fix: redirect stdout to stderr for browser pkg (#689)
Browse files Browse the repository at this point in the history
Co-authored-by: Berkay Beraby <[email protected]>
  • Loading branch information
ShawkyZ and BBerabi authored Oct 8, 2024
1 parent ce40327 commit 990ddda
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
3 changes: 1 addition & 2 deletions domain/ide/command/open_browser.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (

"github.com/rs/zerolog"

"github.com/snyk/go-application-framework/pkg/auth"
"github.com/snyk/snyk-ls/internal/types"
)

Expand All @@ -37,6 +36,6 @@ func (cmd *openBrowserCommand) Command() types.CommandData {
func (cmd *openBrowserCommand) Execute(ctx context.Context) (any, error) {
url := cmd.command.Arguments[0].(string)
cmd.logger.Debug().Str("method", "openBrowserCommand.Execute").Msgf("opening browser url %s", url)
auth.OpenBrowser(url)
types.DefaultOpenBrowserFunc(url)
return nil, nil
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ require (
github.com/otiai10/copy v1.14.0
github.com/pact-foundation/pact-go v1.10.0
github.com/pingcap/errors v0.11.4
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8
github.com/pkg/errors v0.9.1
github.com/puzpuzpuz/xsync v1.5.2
github.com/puzpuzpuz/xsync/v3 v3.4.0
Expand Down Expand Up @@ -98,7 +99,6 @@ require (
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/perimeterx/marshmallow v1.1.5 // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
Expand Down
9 changes: 6 additions & 3 deletions internal/types/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ package types

import (
"context"
"github.com/pkg/browser"
"os"
"sync"

"github.com/snyk/go-application-framework/pkg/auth"
)

const (
Expand All @@ -47,7 +47,10 @@ const (
)

var (
DefaultOpenBrowserFunc = func(url string) { auth.OpenBrowser(url) }
DefaultOpenBrowserFunc = func(url string) {
browser.Stdout = os.Stderr
_ = browser.OpenURL(url)
}
)

type Command interface {
Expand Down

0 comments on commit 990ddda

Please sign in to comment.