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