Showing the changes to apps/server/src/codexTextGenerator.ts (1 of 6 files). Show all
Unified · Split
| @@ -117,9 +117,11 @@ async function runCodexJson<T>({ · 116 unmodified lines | ||
| 117 | 117 | "codex-schema", |
| 118 | 118 | JSON.stringify(outputSchemaJson), |
| 119 | 119 | ); |
| 120 | − const outputPath = await writeTempFile("codex-output", ""); | |
| 120 | + let outputPath: string | null = null; | |
| 121 | 121 | |
| 122 | 122 | try { |
| 123 | + outputPath = await writeTempFile("codex-output", ""); | |
| 124 | + | |
| 123 | 125 | await runProcess( |
| 124 | 126 | "codex", |
| 125 | 127 | [ |
| @@ -154,7 +156,10 @@ async function runCodexJson<T>({ · 28 unmodified lines | ||
| 154 | 156 | |
| 155 | 157 | return parse(parsedJson); |
| 156 | 158 | } finally { |
| 157 | − await Promise.all([safeUnlink(schemaPath), safeUnlink(outputPath)]); | |
| 159 | + await Promise.all([ | |
| 160 | + safeUnlink(schemaPath), | |
| 161 | + ...(outputPath ? [safeUnlink(outputPath)] : []), | |
| 162 | + ]); | |
| 158 | 163 | } |
| 159 | 164 | } |
| 160 | 165 | |