File size: 375 Bytes
46fcec6
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import { unlink, rm } from "node:fs/promises"

export async function deleteFile(filePath: string, debug?: boolean): Promise<boolean> {
  try {
    await rm(filePath, { recursive: true, force: true })
    // await unlink(filePath)
    return true
  } catch (err) {
    if (debug) {
      console.error(`failed to unlink file at ${filePath}: ${err}`)
    }
  }
  return false
}