write-dir-safe

Create directories and their parents recursively

Usage no npm install needed!

<script type="module">
  import writeDirSafe from 'https://cdn.skypack.dev/write-dir-safe';
</script>

README


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

API

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 DependenciesDavid


License license

MIT


Related Packages