Skip to content

Commit

Permalink
fix(cmd): set core.ConfigPath on init
Browse files Browse the repository at this point in the history
  • Loading branch information
b5 committed Jun 11, 2018
1 parent 408d521 commit 9e841b8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions cmd/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type PathFactory func() (string, string)
func EnvPathFactory() (string, string) {
home, err := homedir.Dir()
if err != nil {
panic(err)
return "", ""
}

Expand Down
10 changes: 7 additions & 3 deletions cmd/qri.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ func NewQriCommand(pf PathFactory, in io.Reader, out, err io.Writer) *cobra.Comm
ioStreams := IOStreams{In: in, Out: out, ErrOut: err}
qriPath, ipfsPath := pf()
opt := NewQriOptions(qriPath, ipfsPath, ioStreams)
// initializeCLI()

// TODO: write a test that verifies this works with our new yaml config
// RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $QRI_PATH/config.yaml)")
Expand Down Expand Up @@ -105,7 +104,12 @@ func NewQriOptions(qriPath, ipfsPath string, ioStreams IOStreams) *QriOptions {

func (o *QriOptions) init() (err error) {
initBody := func() {
if err = core.LoadConfig(core.ConfigFilepath); err != nil {
cfgPath := filepath.Join(o.qriRepoPath, "config.yaml")

// TODO - need to remove global config state in core, then remove this
core.ConfigFilepath = cfgPath

if err = core.LoadConfig(cfgPath); err != nil {
return
}
o.config = core.Config
Expand All @@ -119,7 +123,7 @@ func (o *QriOptions) init() (err error) {
}

// for now this just checks for an existing config file
if _, e := os.Stat(filepath.Join(o.qriRepoPath, "config.yaml")); os.IsNotExist(e) {
if _, e := os.Stat(cfgPath); os.IsNotExist(e) {
err = fmt.Errorf("no qri repo found, please run `qri setup`")
return
}
Expand Down

0 comments on commit 9e841b8

Please sign in to comment.