Remove files without try catch
npm install remove-file-safeRemove files without try catch.
_If I should maintain this repo, please ⭐️_
_DM me on Twitter if you have questions or suggestions._
---
> Remove files without try catch.
- Returns true if file no longer exists.
- Returns false if unable to remove file.
- Returns undefined on other errors (ex: permission denied) rather than throwing.
Unless the unsafe flag is set, only files inside the current working directory or OS temp directory will be removed.
``sh`
yarn add remove-file-safe
`sh`
npm install remove-file-safe
`sh`
pnpm add remove-file-safe
`ts
import { removeFile, removeFileSync, Options } from "remove-file-safe";
function removeFile(path: string, options?: Options): Promise
function removeFileSync(path: string, options?: Options): boolean | undefined;
type Options = {
/**
* Allow removals outside of current working directory, or OS temp directory. Default: false``
*/
unsafe?: boolean;
};
- is-path-inside: Check if a path is inside another path
- @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.
- fs-safe: A simple fs wrapper that doesn't throw
- read-file-safe: Read files without try catch
- write-file-safe: Write files, and parent directories if necessary
- read-dir-safe: Read directories recursively or non-recursively
- write-dir-safe: Create directories and their parents recursively
- remove-dir-safe: Remove directories recursively or non-recursively