sindresorhus/tempy

Temporary file or directory not cleaned up when a task callback throws an error

mvila opened this issue · 1 comments

mvila commented

The temporary file or directory is not cleaned up when a task callback throws an error, which doesn't feel like the expected behavior to me.

Example:

const tempy = require('tempy');
const fs = require('fs');

let createdTempDirectory;

await tempy.directory.task(async (tempDirectory) => {
  createdTempDirectory = tempDirectory;
  throw new Error('Something went wrong');
});

fs.existsSync(createdTempDirectory); // => true

Not intended behavior. Just an oversight.

// @Richienb