write-file-safe

Write files atomically and create parent directories if necessary

Usage no npm install needed!

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

README

write-file-safe

NPM TypeScript Coverage Status GitHub Stars Twitter Follow

Write files atomically and create parent directories if necessary.

Installation

yarn add write-file-safe
npm install write-file-safe

API

import { writeFile, writeFileSync, Options } from "write-file-safe";

function writeFile(path: string, content?: string | Buffer): Promise<boolean>;

function writeFileSync(path: string, content?: string | Buffer): boolean;

type Options = {
  /**
   * Recursively create parent directories if needed. Default: `true`
   */
  recursive?: boolean;
  /**
   * Ensure file ends with a newline. Default: `true`
   */
  appendNewline?: boolean;
}

Dependenciesdependencies


Dev DependenciesDavid


License license

MIT

Related Packages