-
Notifications
You must be signed in to change notification settings - Fork 376
Open
Labels
Description
There is a pattern internal to web-ext that is becoming cumbersome and hard to deal with. It looks like:
import {withTempDir} from '../../src/util/temp-dir';
withTempDir(
(tmpDir) => Promise.resolve(tmpDir.path()))
.then((tmpPath) => {
// Do something with tmpPath.
})
});Running a promise inside of a callback is necessary because the temp dir is torn down after the promise succeeds or fails. We can just make the temp dir clean up after itself when the process exits. However, there may still be some cases where we want immediate cleanup, such as a long running session where a file watcher will need to create many temp dirs.