VideoChain-API / src /utils /deleteFileIfExists.mts
jbilcke-hf's picture
jbilcke-hf HF staff
ok! now, time to debug and build the frontend..
5dfc565
raw
history blame
309 Bytes
import { existsSync, promises as fs } from "node:fs"
export const deleteFileIfExists = async (filePath: string) => {
if (existsSync(filePath)) {
try {
await fs.unlink(filePath)
return true
} catch (err) {
console.log(`failed to delete file ${filePath}`)
}
}
return false
}