Skip to content

Commit ea49433

Browse files
authored
Fix init failing when mobs_dir is outside repo root (#21)
1 parent 7d59cfc commit ea49433

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

internal/mob/mob.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,11 @@ func SaveConfig(repoRoot string, cfg *Config) error {
146146
if err != nil {
147147
return fmt.Errorf("failed to marshal config: %w", err)
148148
}
149-
return os.WriteFile(filepath.Join(repoRoot, ConfigFile), append(data, '\n'), 0644)
149+
p := filepath.Join(repoRoot, ConfigFile)
150+
if err := os.MkdirAll(filepath.Dir(p), 0755); err != nil {
151+
return fmt.Errorf("failed to create config directory: %w", err)
152+
}
153+
return os.WriteFile(p, append(data, '\n'), 0644)
150154
}
151155

152156
// Reconcile removes mobs from config whose worktree no longer exists on disk.

0 commit comments

Comments
 (0)