https://github.com/jaydenseric/disposable-directory
Asynchronously creates a disposable directory in the OS temporary directory that gets deleted after the callback is done or errors.
https://github.com/jaydenseric/disposable-directory
esm maintained mjs node npm typescript
Last synced: about 1 year ago
JSON representation
Asynchronously creates a disposable directory in the OS temporary directory that gets deleted after the callback is done or errors.
- Host: GitHub
- URL: https://github.com/jaydenseric/disposable-directory
- Owner: jaydenseric
- License: mit
- Created: 2019-12-30T06:03:32.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-08-18T03:13:58.000Z (almost 4 years ago)
- Last Synced: 2025-04-10T15:58:58.884Z (about 1 year ago)
- Topics: esm, maintained, mjs, node, npm, typescript
- Language: JavaScript
- Homepage: https://npm.im/disposable-directory
- Size: 98.6 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Changelog: changelog.md
- Funding: .github/funding.yml
- License: license.md
Awesome Lists containing this project
README
# disposable-directory
Asynchronously creates a disposable directory in the OS temporary directory that gets deleted after the callback is done or errors.
## Installation
To install [`disposable-directory`](https://npm.im/disposable-directory) with [npm](https://npmjs.com/get-npm), run:
```sh
npm install disposable-directory
```
Then, import and use the function [`disposableDirectory`](./disposableDirectory.mjs).
## Examples
How to use a disposable directory:
```js
import disposableDirectory from "disposable-directory";
disposableDirectory(async (directoryPath) => {
// Use the directory here.
})
.then(() => {
// The directory is gone.
})
.catch(() => {
// The directory is gone.
});
```
## Requirements
Supported operating systems:
- Linux
- macOS
Supported runtime environments:
- [Node.js](https://nodejs.org) versions `^14.17.0 || ^16.0.0 || >= 18.0.0`.
Projects must configure [TypeScript](https://typescriptlang.org) to use types from the ECMAScript modules that have a `// @ts-check` comment:
- [`compilerOptions.allowJs`](https://typescriptlang.org/tsconfig#allowJs) should be `true`.
- [`compilerOptions.maxNodeModuleJsDepth`](https://typescriptlang.org/tsconfig#maxNodeModuleJsDepth) should be reasonably large, e.g. `10`.
- [`compilerOptions.module`](https://typescriptlang.org/tsconfig#module) should be `"node16"` or `"nodenext"`.
## Exports
The [npm](https://npmjs.com) package [`disposable-directory`](https://npm.im/disposable-directory) features [optimal JavaScript module design](https://jaydenseric.com/blog/optimal-javascript-module-design). These ECMAScript modules are exported via the [`package.json`](./package.json) field [`exports`](https://nodejs.org/api/packages.html#exports):
- [`disposableDirectory.mjs`](./disposableDirectory.mjs)