Skip to content
This repository was archived by the owner on Feb 27, 2018. It is now read-only.

Commit 394bf16

Browse files
committed
Merge pull request #73 from SvenDowideit/test-for-cfg-dir-existance
Test for cfg dir existance
2 parents 788d1db + cfb5cd1 commit 394bf16

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

config.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ func getCfgDir(name string) (string, error) {
5151

5252
// *nix
5353
if home := os.Getenv("HOME"); home != "" {
54-
return filepath.Join(home, name), nil
54+
dir := filepath.Join(home, name)
55+
if _, err := os.Stat(dir); err == nil {
56+
return dir, nil
57+
}
5558
}
5659

5760
// Windows
@@ -61,15 +64,18 @@ func getCfgDir(name string) (string, error) {
6164
"USERPROFILE",
6265
} {
6366
if val := os.Getenv(env); val != "" {
64-
return filepath.Join(val, "boot2docker"), nil
67+
dir := filepath.Join(val, "boot2docker")
68+
if _, err := os.Stat(dir); err == nil {
69+
return dir, nil
70+
}
6571
}
6672
}
6773
// Fallback to current working directory as a last resort
6874
cwd, err := os.Getwd()
6975
if err != nil {
7076
return "", err
7177
}
72-
return filepath.Join(cwd, name), nil
78+
return cwd, nil
7379
}
7480

7581
// Read configuration from both profile and flags. Flags override profile.

0 commit comments

Comments
 (0)