Skip to content
Merged
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
26 changes: 1 addition & 25 deletions configs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package configs

import (
"os"
"os/user"
"path"
"path/filepath"
"reflect"
Expand Down Expand Up @@ -66,25 +65,6 @@ func (c *Configs) marshalConfig(config *Config, cfg interface{}) error {
return err
}

func fetchHomeDir() (homeDir *string, err error) {
// In OSX BigSur, or terminals where the user isn't set
// user.Current cannot function
// As a backstop (We should be crosscompiling using clang)
// hoist the dirhir from env
defer func() {
if r := recover(); r != nil {
home := os.Getenv("HOME")
homeDir = &home
err = nil
}
}()
user, err := user.Current()
if err != nil {
return nil, err
}
return &user.HomeDir, nil
}

func New() *Configs {
// Configs stored in projects (<project>/.railway)
// Includes projectId, environmentId, etc
Expand All @@ -110,11 +90,7 @@ func New() *Configs {
// Configs stored in root (~/.railway)
// Includes token, etc
userViper := viper.New()
homeDir, err := fetchHomeDir()
if err != nil {
panic(err)
}
userPath := path.Join(*homeDir, ".railway/config.json")
userPath := path.Join(os.Getenv("HOME"), ".railway/config.json")
userViper.SetConfigFile(userPath)
userViper.ReadInConfig()

Expand Down