File size: 309 Bytes
5dfc565
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
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
}