fix could-not-access error

This commit is contained in:
Jesse Duffield 2022-11-11 12:16:38 +11:00
parent ab03cf8bcf
commit e8b97c9fe2
22 changed files with 80 additions and 1 deletions

View file

@ -45,6 +45,15 @@ func (s *Shell) CreateFile(path string, content string) *Shell {
return s
}
func (s *Shell) CreateDir(path string) *Shell {
fullPath := filepath.Join(s.dir, path)
if err := os.MkdirAll(fullPath, 0o755); err != nil {
panic(fmt.Sprintf("error creating directory: %s\n%s", fullPath, err))
}
return s
}
func (s *Shell) UpdateFile(path string, content string) *Shell {
fullPath := filepath.Join(s.dir, path)
err := os.WriteFile(fullPath, []byte(content), 0o644)