mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-28 04:19:41 -08:00
parent
c03ee35107
commit
9f70320525
|
@ -416,6 +416,7 @@ func (env *Shell) HasFiles(pattern string) bool {
|
|||
matches, err := fs.Glob(fileSystem, pattern)
|
||||
if err != nil {
|
||||
env.Error(err)
|
||||
env.Debug("false")
|
||||
return false
|
||||
}
|
||||
for _, match := range matches {
|
||||
|
@ -423,8 +424,10 @@ func (env *Shell) HasFiles(pattern string) bool {
|
|||
if err != nil || file.IsDir() {
|
||||
continue
|
||||
}
|
||||
env.Debug("true")
|
||||
return true
|
||||
}
|
||||
env.Debug("false")
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -434,6 +437,7 @@ func (env *Shell) HasFilesInDir(dir, pattern string) bool {
|
|||
matches, err := fs.Glob(fileSystem, pattern)
|
||||
if err != nil {
|
||||
env.Error(err)
|
||||
env.Debug("false")
|
||||
return false
|
||||
}
|
||||
hasFilesInDir := len(matches) > 0
|
||||
|
|
|
@ -60,14 +60,16 @@ func (d *Docker) Enabled() bool {
|
|||
// Check if there is a file named `$HOME/.docker/config.json` or `$DOCKER_CONFIG/config.json`
|
||||
// Return the current context if it is not empty and not `default`
|
||||
for _, f := range d.configFiles() {
|
||||
if !d.env.HasFiles(f) {
|
||||
data := d.env.FileContent(f)
|
||||
if len(data) == 0 {
|
||||
continue
|
||||
}
|
||||
data := d.env.FileContent(f)
|
||||
|
||||
var cfg DockerConfig
|
||||
if err := json.Unmarshal([]byte(data), &cfg); err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
if len(cfg.CurrentContext) > 0 && cfg.CurrentContext != "default" {
|
||||
d.Context = cfg.CurrentContext
|
||||
return true
|
||||
|
|
Loading…
Reference in a new issue