write-dir-safe
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

write-dir-safe

NPM TypeScript Coverage Status

Create directories and their parents recursively.

If I should maintain this repo, please ⭐️ GitHub stars

DM me on Twitter if you have questions or suggestions. Twitter


Create directories and their parents recursively.

  • Returns true if directory now exists.
  • Returns false if unable to create directory.
  • Returns undefined on other errors (ex: permission denied) rather than throwing.

Installation

yarn add write-dir-safe
npm install write-dir-safe
pnpm add write-dir-safe

Usage

import { writeDir, writeDirSync, Options } from "write-dir-safe";

function writeDir(path: string, options: Options): Promise<boolean | undefined>;

function writeDirSync(path: string, options: Options): boolean | undefined;

type Options = {
  /**
   * Recursively create parent directories as well. Default: `true`
   */
  recursive?: boolean;
};

Dev Dependencies

  • @types/mock-fs: TypeScript definitions for mock-fs
  • @types/node: TypeScript definitions for Node.js
  • autorepo: Autorepo abstracts away your dev dependencies, providing a single command to run all of your scripts.
  • mock-fs: A configurable mock file system. You know, for testing.
  • read-file-safe: Read files without try catch

License license

MIT - MIT License


Related Packages

Dependencies (0)

    Dev Dependencies (5)

    Package Sidebar

    Install

    npm i write-dir-safe

    Weekly Downloads

    1,032

    Version

    2.0.1

    License

    MIT

    Unpacked Size

    6.58 kB

    Total Files

    8

    Last publish

    Collaborators

    • bconnorwhite