with-tmp
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

with-tmp Build Status

Easily create a temporary directory without having to worry about cleanup.

import withTmpdir from "with-tmp";
 
await withTmpdir("my-tmp-dir", dir => {
  const path = path.join(dir, "my-file");
  fs.writeFileSync(path, "content");
}); // tmpdir is cleaned up

Do tasks from within the temporary directory without having to worry about restoring your environment.

import { withinTmpdir } from "with-tmp";
 
process.cwd(); // => /home/me/workspace
await withinTmpdir("my-other-tmp-dir", dir => {
  process.cwd(); // => /private/var/folders/83/5913m0b1080000gn/T/my-other-tmp-dir2Ivp7V
});

Package Sidebar

Install

npm i with-tmp

Weekly Downloads

0

Version

1.1.1

License

MIT

Unpacked Size

117 kB

Total Files

6

Last publish

Collaborators

  • charleskenney