Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/avivahl/create-temp-directory
Create an empty, unique directory in the current OS's temp directory
https://github.com/avivahl/create-temp-directory
Last synced: 2 months ago
JSON representation
Create an empty, unique directory in the current OS's temp directory
- Host: GitHub
- URL: https://github.com/avivahl/create-temp-directory
- Owner: AviVahl
- License: mit
- Created: 2018-07-29T21:26:45.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2024-10-09T08:55:27.000Z (3 months ago)
- Last Synced: 2024-10-11T10:02:42.341Z (2 months ago)
- Language: TypeScript
- Size: 235 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# create-temp-directory
[![npm version](https://img.shields.io/npm/v/create-temp-directory.svg)](https://www.npmjs.com/package/create-temp-directory)
[![tests](https://github.com/AviVahl/create-temp-directory/actions/workflows/tests.yml/badge.svg)](https://github.com/AviVahl/create-temp-directory/actions/workflows/tests.yml)Create an empty, unique directory in the current OS's temp directory.
It returns an absolute `path` and a `remove()` function. Useful for tests.## Getting started
Install the library as a `devDependency` in an existing project:
```
npm i create-temp-directory --save-dev
```## Example usage
```ts
import { createTempDirectory, ITempDirectory } from "create-temp-directory";describe("test suite", () => {
let tempDir: ITempDirectory;beforeEach(async () => {
tempDir = await createTempDirectory();
});
afterEach(async () => {
await tempDir.remove();
});it("some test", () => {
const tempFilePath = path.join(tempDir.path, "temp-file");
// the rest of the test...
});
});
```_NOTE: The above example is written using TypeScript. In pure JavaScript, you do not need to import/use `ITempDirectory`._
## License
MIT