Skip to content

Is there a recommended way to remove temporary directories and files? #14715

Answered by nayeemrmn
milotheirself asked this question in Q&A
Discussion options

You must be logged in to vote

Normally you should remove them right after using them in a finally block:

const tempPath = await Deno.makeTempDir({ prefix: `my-prefix-` });
try {
  // code that uses `tempPath`...
} finally {
  await Deno.remove(tempPath, { recursive: true });
}

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by milotheirself
Comment options

You must be logged in to vote
2 replies
@milotheirself
Comment options

@cjihrig
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants