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

2.0.3 • Public • Published

write-file-safe

NPM TypeScript Coverage Status

Write files atomically, and create parent directories if necessary.

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

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


Installation

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

Usage

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;
  /**
   * Write even if file already exists. Default: `true`
   */
  overwrite?: boolean;
};


Dependenciesdependencies


Dev Dependencies

  • autorepo: Autorepo abstracts away your dev dependencies, providing a single command to run all of your scripts.

License license

MIT - MIT License


Related Packages

Package Sidebar

Install

npm i write-file-safe

Weekly Downloads

1,141

Version

2.0.3

License

MIT

Unpacked Size

13.1 kB

Total Files

8

Last publish

Collaborators

  • bconnorwhite