fix(utils): handle file write failures with rollback
All checks were successful
Auto Changelog & Release / detect-version-change (push) Successful in 3s
Auto Changelog & Release / release (push) Has been skipped
Auto Changelog & Release / changelog-only (push) Successful in 5s

- Add error handling and rollback logic for unit file writes
- Prevent partial file writes by removing created files on failure
- Update tests to reflect new return type and error handling
This commit is contained in:
2025-05-21 09:51:16 +02:00
parent a76417ce1d
commit bd71b8ee14
3 changed files with 30 additions and 8 deletions

View File

@@ -12,14 +12,20 @@ export async function generateUnitFiles(options: TimerOptions): Promise<void> {
console.log(`\n===== ${name}.timer =====`);
console.log(timerUnit);
} else {
const { servicePath, timerPath } = await writeUnitFiles(
const result = await writeUnitFiles(
name,
serviceUnit,
timerUnit,
options,
);
console.log(`Service unit written to: ${servicePath}`);
console.log(`Timer unit written to: ${timerPath}`);
if (result) {
const { servicePath, timerPath } = result;
console.log(`Service Unit geschrieben in: ${servicePath}`);
console.log(`Timer Unit geschrieben in: ${timerPath}`);
} else {
return;
}
console.log(`\nℹ️ Hinweis:`);