fix: properly handle directory replacement

The previous version _also_ deleted the temp working dir, causing issues with subsequent directory access.
This commit is contained in:
Jose Diaz-Gonzalez
2021-07-10 00:48:47 -04:00
parent fda75cbaa5
commit 377ca5ca22
4 changed files with 36 additions and 8 deletions

View File

@@ -0,0 +1,20 @@
package builder
import (
"io/ioutil"
"os"
"path"
)
func removeAllContents(basePath string) error {
dir, err := ioutil.ReadDir(basePath)
if err != nil {
return err
}
for _, d := range dir {
os.RemoveAll(path.Join([]string{basePath, d.Name()}...))
}
return nil
}