Write files atomically, and create parent directories if necessary
npm install write-file-safeWrite files atomically, and create parent directories if necessary.
_If I should maintain this repo, please ⭐️_
_DM me on Twitter if you have questions or suggestions._
---
``sh`
yarn add write-file-safe
`sh`
npm install write-file-safe
`sh`
pnpm add write-file-safe
`ts
import { writeFile, writeFileSync, Options } from "write-file-safe";
function writeFile(path: string, content?: string | Buffer): Promise
function writeFileSync(path: string, content?: string | Buffer): boolean;
type Options = {
/**
* Recursively create parent directories if needed. Default: truetrue
*/
recursive?: boolean;
/**
* Ensure file ends with a newline. Default: true
*/
appendNewline?: boolean;
/**
* Write even if file already exists. Default: ``
*/
overwrite?: boolean;
};
- file-exists-safe: Check if a file exists without try catch
- remove-file-safe: Remove files without try catch
- terminating-newline: Add or remove a terminating newline
- write-dir-safe: Create directories and their parents recursively
- autorepo: Autorepo abstracts away your dev dependencies, providing a single command to run all of your scripts.
MIT - _MIT License_
- fs-safe: A simple fs wrapper that doesn't throw
- read-file-safe: Read files without try catch
- remove-file-safe: Remove files without try catch
- read-dir-safe: Read directories recursively or non-recursively
- remove-dir-safe: Remove directories recursively or non-recursively
- write-dir-safe: Create directories and their parents recursively