-
Notifications
You must be signed in to change notification settings - Fork 97
Closed
Description
Apparently, node-tmp
doesn't properly cleanup in some situations. It would be nice to have a method on tmp
like this:
tmp.forceCleanup = (names, cb) => {
if (!names) return tmp._cleanupAllCreatedFilesAndDirs(cb);
// run cleanup jobs in parallel, calls cb when all are done
parallel(names.map(name => done => tmp._cleanupFileOrDir(name, done)), cb)
}
usage:
const tmp = require("tmp")
process.on("SIGINT", () => tmp.forceCleanup())
// my code ...
what i'll probably do currently (a hack...):
const tmp = require("tmp")
const fs = require("fs")
const { join } = require("path")
// keep track of all created crap, or if you use a single parent dir:
// delete all stuff under parent dir that starts with tmp-
process.on("SIGINT", () => {
fs.readdir(parentDir, (err, files) => {
//handle err
for (let file of files){
if (file.slice(0,4) === "tmp-"){
// brevity (no err handling/file checking)
fs.unlink(join(parentDir, file))
}
}
})
})
Metadata
Metadata
Assignees
Labels
No labels