(path string, content string)
| 89 | } |
| 90 | |
| 91 | func (self *Shell) CreateFile(path string, content string) *Shell { |
| 92 | fullPath := filepath.Join(self.dir, path) |
| 93 | |
| 94 | // create any required directories |
| 95 | dir := filepath.Dir(fullPath) |
| 96 | if err := os.MkdirAll(dir, 0o755); err != nil { |
| 97 | self.fail(fmt.Sprintf("error creating directory: %s\n%s", dir, err)) |
| 98 | } |
| 99 | |
| 100 | err := os.WriteFile(fullPath, []byte(content), 0o644) |
| 101 | if err != nil { |
| 102 | self.fail(fmt.Sprintf("error creating file: %s\n%s", fullPath, err)) |
| 103 | } |
| 104 | |
| 105 | return self |
| 106 | } |
| 107 | |
| 108 | func (self *Shell) DeleteFile(path string) *Shell { |
| 109 | fullPath := filepath.Join(self.dir, path) |
no test coverage detected