(spellId string, content string)
| 54 | } |
| 55 | |
| 56 | func SaveSpellScript(spellId string, content string) error { |
| 57 | spec := GetSpell(spellId) |
| 58 | if spec == nil { |
| 59 | return fmt.Errorf("spell %q not found", spellId) |
| 60 | } |
| 61 | |
| 62 | scriptPath := spec.GetScriptPath() |
| 63 | |
| 64 | if content == "" { |
| 65 | if err := os.Remove(scriptPath); err != nil && !os.IsNotExist(err) { |
| 66 | return fmt.Errorf("removing spell script: %w", err) |
| 67 | } |
| 68 | return nil |
| 69 | } |
| 70 | |
| 71 | return util.WriteFile(scriptPath, []byte(content), 0644) |
| 72 | } |
no test coverage detected