function ensureGenerated
ensureGenerated(
outPath: string,
generate: () => Promise<void>,
srcPath?: string
): Promise<boolean>

Makes outPath with generate unless it exists. Resolves false when it can't be made, because ffmpeg is missing or failed.

With srcPath, the file it is made from, outPath takes that file's date, and is made again when the two differ: an upload replaced in place, as an avatar or a cover is, gets new copies without anyone deleting the old. Without it, the caller deletes outPath when its source changes.

Parameters

outPath: string
generate: () => Promise<void>
optional
srcPath: string

Return Type

Promise<boolean>

Usage

import { ensureGenerated } from "api/lib/ffmpeg.ts";