MCPcopy
hub / github.com/spicetify/cli / ModifyFile

Function ModifyFile

src/utils/utils.go:234–246  ·  view source on GitHub ↗

ModifyFile opens file, changes file content by executing `repl` callback function and writes new content.

(path string, repl func(string) string)

Source from the content-addressed store, hash-verified

232// ModifyFile opens file, changes file content by executing
233// `repl` callback function and writes new content.
234func ModifyFile(path string, repl func(string) string) {
235 raw, err := os.ReadFile(path)
236 if err != nil {
237 log.Print(err)
238 return
239 }
240
241 content := repl(string(raw))
242
243 if err := os.WriteFile(path, []byte(content), 0700); err != nil {
244 log.Print(err)
245 }
246}
247
248// CreateFile creates a file with given path and content.
249func CreateFile(path string, content string) error {

Callers 10

PatchFunction · 0.92
pushExtensionsFunction · 0.92
htmlModFunction · 0.92
insertCustomAppFunction · 0.92
insertHomeConfigFunction · 0.92
insertSidebarConfigFunction · 0.92
insertExpFeaturesFunction · 0.92
insertVersionInfoFunction · 0.92
StartFunction · 0.92
StartCSSFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected