template / commit
Fix missing OSStat implementation.
monkey-patch.go | 1 + profile.go | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/monkey-patch.go b/monkey-patch.go index e87d0d6..0ce2d18 100644 --- a/monkey-patch.go +++ b/monkey-patch.go @@ -133,6 +133,7 @@ func defaultMonkeyPatch() monkeyPatch { OSChdir: os.Chdir, OSMkdir: os.Mkdir, OSReadDir: os.ReadDir, + OSStat: os.Stat, } } diff --git a/profile.go b/profile.go index 34940a2..0e20175 100644 --- a/profile.go +++ b/profile.go @@ -92,15 +92,16 @@ func processProfile(profile Profile, projectName string, extras map[string]strin return []error{fmt.Errorf("unable to get current working directory: %v", err)} } if profile.TargetDirectory != "" { - if _, err := monkey.OSStat(profile.TargetDirectory); errors.Is(err, os.ErrNotExist) { - err = monkey.OSMkdir(profile.TargetDirectory, 0755) + path := getFullPath(profile.TargetDirectory, usr) + + if _, err := monkey.OSStat(path); errors.Is(err, os.ErrNotExist) { + err = monkey.OSMkdir(path, 0755) if err != nil { return []error{fmt.Errorf("unable to create target directory: %v", err)} } } // change cwd to the profile's path, if one is specified - path := getFullPath(profile.TargetDirectory, usr) err = monkey.OSChdir(path) if err != nil { return []error{fmt.Errorf("unable to change directory (1) to %v: %v", path, err)}