Skip to content
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

fix: use filepath instead of path for Windows compatibility #1542

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmd/appstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"io"
"io/fs"
"os"
"path"
"path/filepath"

"github.com/cosmos/relayer/v2/relayer"
"github.com/gofrs/flock"
Expand Down Expand Up @@ -48,7 +48,7 @@ func (a *appState) initLogger(configLogLevel string) error {
}

func (a *appState) configPath() string {
return path.Join(a.homePath, "config", "config.yaml")
return filepath.Join(a.homePath, "config", "config.yaml")
}

// loadConfigFile reads config file into a.Config if file is present.
Expand Down Expand Up @@ -197,7 +197,7 @@ func (a *appState) addPathFromUserInput(
}

func (a *appState) performConfigLockingOperation(ctx context.Context, operation func() error) error {
lockFilePath := path.Join(a.homePath, "config", "config.lock")
lockFilePath := filepath.Join(a.homePath, "config", "config.lock")
fileLock := flock.New(lockFilePath)
_, err := fileLock.TryLock()
if err != nil {
Expand Down
11 changes: 5 additions & 6 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"io"
"io/ioutil"
"os"
"path"
"path/filepath"
"reflect"
"strings"
Expand Down Expand Up @@ -69,7 +68,7 @@ $ %s cfg list`, appName, defaultHome, appName)),
return err
}

cfgPath := path.Join(home, "config", "config.yaml")
cfgPath := filepath.Join(home, "config", "config.yaml")
if _, err := os.Stat(cfgPath); os.IsNotExist(err) {
if _, err := os.Stat(home); os.IsNotExist(err) {
return fmt.Errorf("home path does not exist: %s", home)
Expand Down Expand Up @@ -125,8 +124,8 @@ $ %s cfg i`, appName, defaultHome, appName)),
return err
}

cfgDir := path.Join(home, "config")
cfgPath := path.Join(cfgDir, "config.yaml")
cfgDir := filepath.Join(home, "config")
cfgPath := filepath.Join(cfgDir, "config.yaml")

// If the config doesn't exist...
if _, err := os.Stat(cfgPath); os.IsNotExist(err) {
Expand Down Expand Up @@ -178,7 +177,7 @@ $ %s cfg i`, appName, defaultHome, appName)),
// the error is logged.
// An error is only returned if the directory cannot be read at all.
func addChainsFromDirectory(ctx context.Context, stderr io.Writer, a *appState, dir string) error {
dir = path.Clean(dir)
dir = filepath.Clean(dir)
files, err := ioutil.ReadDir(dir)
if err != nil {
return err
Expand Down Expand Up @@ -230,7 +229,7 @@ func addChainsFromDirectory(ctx context.Context, stderr io.Writer, a *appState,
// addPathsFromDirectory returns the first error encountered,
// which means a's paths may include a subset of the path files in dir.
func addPathsFromDirectory(ctx context.Context, stderr io.Writer, a *appState, dir string) error {
dir = path.Clean(dir)
dir = filepath.Clean(dir)
files, err := ioutil.ReadDir(dir)
if err != nil {
return err
Expand Down