(fn: (dir: string) => Promise<T>)
| 187 | } |
| 188 | |
| 189 | async function withTempDir<T>(fn: (dir: string) => Promise<T>): Promise<T> { |
| 190 | ensureFfmpeg() |
| 191 | const dir = await fs.mkdtemp(path.join(os.tmpdir(), 'media-ffmpeg-')) |
| 192 | try { |
| 193 | return await fn(dir) |
| 194 | } finally { |
| 195 | await fs.rm(dir, { recursive: true, force: true }).catch(() => {}) |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | async function writeInput(dir: string, file: MediaFile, index: number): Promise<string> { |
| 200 | const ext = extFromMime(file.mimeType) |
no test coverage detected