Spaces:
Paused
Paused
File size: 424 Bytes
5b3c62d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
import { promises as fs } from "node:fs"
import path from "node:path"
export const deleteFilesWithName = async (dir: string, name: string) => {
for (const file of await fs.readdir(dir)) {
if (file.includes(name)) {
const filePath = path.join(dir, file)
try {
await fs.unlink(filePath)
} catch (err) {
console.error(`failed to unlink file in ${filePath}: ${err}`)
}
}
}
}
|