Skip to content

Commit

Permalink
Remove Home Entirely (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeCooper authored Oct 5, 2020
1 parent adc2078 commit d0e4b99
Showing 1 changed file with 1 addition and 25 deletions.
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

0 comments on commit d0e4b99

Please sign in to comment.