create-temp-directory
TypeScript icon, indicating that this package has built-in type declarations

2.4.0 • Public • Published

create-temp-directory

npm version tests

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

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

Readme

Keywords

none

Package Sidebar

Install

npm i create-temp-directory

Weekly Downloads

2,586

Version

2.4.0

License

MIT

Unpacked Size

9.65 kB

Total Files

13

Last publish

Collaborators

  • avi.vahl