Only use settings.json if ~/.micro exists

Fixes #3
This commit is contained in:
Zachary Yedidia
2016-04-17 21:49:36 -04:00
parent 1defb1d039
commit 648070c6d2

View File

@@ -51,8 +51,15 @@ func InitSettings() {
// WriteSettings writes the settings to the specified filename as JSON
func WriteSettings(filename string) error {
txt, _ := json.MarshalIndent(settings, "", " ")
err := ioutil.WriteFile(filename, txt, 0644)
var err error
home, err := homedir.Dir()
if err != nil {
return err
}
if _, e := os.Stat(home + "/.micro"); e == nil {
txt, _ := json.MarshalIndent(settings, "", " ")
err = ioutil.WriteFile(filename, txt, 0644)
}
return err
}