mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-25 08:31:03 +00:00
create config if it does not exist
This commit is contained in:
parent
b9bf469695
commit
02753cee61
1 changed files with 16 additions and 1 deletions
|
|
@ -2,6 +2,7 @@ package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -293,7 +294,21 @@ func loadUserConfigWithDefaults(configDir string) (*UserConfig, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadUserConfig(configDir string, base *UserConfig) (*UserConfig, error) {
|
func loadUserConfig(configDir string, base *UserConfig) (*UserConfig, error) {
|
||||||
content, err := ioutil.ReadFile(filepath.Join(configDir, "config.yml"))
|
fileName := filepath.Join(configDir, "config.yml")
|
||||||
|
|
||||||
|
if _, err := os.Stat(fileName); err != nil {
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
file, err := os.Create(fileName)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
file.Close()
|
||||||
|
} else {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
content, err := ioutil.ReadFile(fileName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue