https://github.com/0xch4z/with-tmp
Easily create and use temp dirs without worrying about clean up
https://github.com/0xch4z/with-tmp
node tempdir testing typescript
Last synced: about 1 month ago
JSON representation
Easily create and use temp dirs without worrying about clean up
- Host: GitHub
- URL: https://github.com/0xch4z/with-tmp
- Owner: 0xch4z
- Created: 2019-05-24T07:11:42.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-06-02T00:30:46.000Z (about 6 years ago)
- Last Synced: 2025-10-09T05:07:02.305Z (8 months ago)
- Topics: node, tempdir, testing, typescript
- Language: TypeScript
- Homepage:
- Size: 534 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# with-tmp [](https://travis-ci.org/charliekenney23/with-tmp) [](https://greenkeeper.io/)
### Easily create a temporary directory without having to worry about cleanup.
```typescript
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.
```typescript
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
});
```