Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

disposable-directory

jaydenseric8kMIT6.0.0

Asynchronously creates a disposable directory in the OS temporary directory that gets deleted after the callback is done or errors.

disposable, temporary, directory, tmp, dir, esm, mjs

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 with npm, run:

npm install disposable-directory

Then, import and use the function disposableDirectory.

Examples

How to use a disposable directory:

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 versions ^14.17.0 || ^16.0.0 || >= 18.0.0.

Projects must configure TypeScript to use types from the ECMAScript modules that have a // @ts-check comment:

Exports

The npm package disposable-directory features optimal JavaScript module design. These ECMAScript modules are exported via the package.json field exports:

changelog

disposable-directory changelog

6.0.0

Major

  • Updated Node.js support to ^14.17.0 || ^16.0.0 || >= 18.0.0.
  • Updated dev dependencies, some of which require newer Node.js versions than previously supported.
  • Removed the package main field.
  • Use the node: URL scheme for Node.js builtin module imports.
  • Migrated from the Node.js builtin module fs to node:fs/promises.
  • Replaced the function fsPathRemove with the function rm from the Node.js builtin module node:fs/promises.

Patch

  • Updated jsconfig.json:
    • Set compilerOptions.maxNodeModuleJsDepth to 10.
    • Set compilerOptions.module to nodenext.
  • Updated ESLint config.
  • Updated GitHub Actions CI config:
    • Run tests with Node.js v14, v16, v18.
    • Updated actions/checkout to v3.
    • Updated actions/setup-node to v3.
  • Revamped the readme:

5.0.2

Patch

  • Updated dev dependencies.
  • Simplified dev dependencies and config for ESLint.
  • Removed the jsdoc-md dev dependency and the related package scripts, replacing the readme “API” section with manually written “Examples” and “Exports” sections.
  • Updated jsconfig.json to disable TypeScript automatic type acquisition for the project.
  • Moved a JSDoc @typedef block to after the module default export.
  • Added a license.md MIT License file.

5.0.1

Patch

  • Moved @types/node from package devDependencies to dependencies, using * for the version.
  • Updated dev dependencies.

5.0.0

Major

  • Updated Node.js support to ^12.22.0 || ^14.17.0 || >= 16.0.0.
  • Updated dev dependencies, some of which require newer Node.js versions than previously supported.
  • Removed ./package from the package exports field; the full package.json filename must be used in a require path.
  • Renamed index.mjs to disposableDirectory.mjs and added it to the package exports field.
  • Implemented TypeScript types via JSDoc comments.

Patch

  • Simplified package scripts.
  • Check TypeScript types via a new package types script.
  • Also run GitHub Actions CI with Node.js v17, and drop v15.
  • Configured Prettier option singleQuote to the default, false.
  • Reorganized the private and test files, individually listing published files in the the package files field.
  • Renamed imports in the test index module.
  • Documentation tweaks.

4.0.0

Major

  • Updated Node.js support to ^12.20 || >= 14.13.
  • Updated dev dependencies, some of which require newer Node.js versions than were previously supported.
  • The API is now ESM in .mjs files instead of CJS in .js files, accessible via import but not require.
  • The function disposableDirectory is now only accessible via a default import from the main index.
  • The function disposableDirectory now throws a TypeError if argument 1 callback isn’t a function.
  • Added back a package sideEffects field.

Patch

  • Stop using hard-rejection to detect unhandled Promise rejections in tests, as Node.js v15+ does this natively.
  • Simplified the package scripts now that jsdoc-md v10 automatically generates a Prettier formatted readme.
  • Added a package test:jsdoc script that checks the readme API docs are up to date with the source JSDoc.
  • Updated GitHub Actions CI config:
    • Also run tests with Node.js v16.
    • Updated actions/checkout to v2.
    • Updated actions/setup-node to v2.
    • Don’t specify the CI environment variable as it’s set by default.
  • Simplified the ESLint config.
  • Removed npm-debug.log from the .gitignore file as npm v4.2.0+ doesn’t create it in the current working directory.
  • Updated the private function fsPathRemove:
    • Throw a more specific TypeError when argument 1 path isn’t a string.
    • Resolve void.
  • Simplified a rejects assertion in fsPathRemove tests.
  • Removed the test helper function sleep.
  • Replaced the test helper function fsPathExists with the Node.js fs.existsSync function.
  • Readme tweaks.

3.0.0

Major

  • Updated the package engines.node field to ^10.17.0 || ^12.0.0 || >= 13.7.0.
  • Updated dev dependencies, some of which require newer Node.js versions than previously supported.
  • Removed the package module and sideEffects fields.
  • Changed the file structure, so deep import/require paths may need to be updated.

Patch

  • Updated the package keywords field.
  • Also run GitHub Actions with Node.js v15, and not v13.
  • Simplified the GitHub Actions CI config with the npm install-test command.
  • Updated EditorConfig.
  • Correct the supported Node.js versions documented in the readme.
  • Prettier JSDoc example code.
  • Documented how to import or require the disposableDirectory function.

2.0.0

Major

  • Added a package exports field and a lib/index.mjs file to support native ESM in Node.js.
  • Added package sideEffects and module fields for bundlers such as Webpack.
  • Undocumented internal helpers are now private, and can no longer be imported from packages outside this package.
  • Updated the package engines.node field to 10 - 12 || >= 13.7 to reflect the package exports related breaking changes.

Patch

  • Updated dev dependencies.
  • Added a new hard-rejection dev dependency to ensure unhandled rejections in tests exit the process with an error.
  • Improved the package prepare:prettier and test:prettier scripts.
  • Configured Prettier option semi to the default, true.
  • Reorganized the test files.
  • Simplified test/index.js.
  • Ensure GitHub Actions run on pull request.

1.0.0

Initial release.