MCPcopy
hub / github.com/jesseduffield/lazygit / CreateFile

Method CreateFile

pkg/integration/components/shell.go:91–106  ·  view source on GitHub ↗
(path string, content string)

Source from the content-addressed store, hash-verified

89}
90
91func (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
108func (self *Shell) DeleteFile(path string) *Shell {
109 fullPath := filepath.Join(self.dir, path)

Calls 3

DirMethod · 0.80
failMethod · 0.80
SprintfMethod · 0.65

Tested by

no test coverage detected