Skip to content

Defer temp dir teardown until the process exits #239

@kumar303

Description

@kumar303

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions