# remove-file-safe

> Remove files without try catch

Latest version **3.0.0** (published 2023-01-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install remove-file-safe
pnpm add remove-file-safe
yarn add remove-file-safe
bun add remove-file-safe
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2023-01-12 |
| First published | 2020-10-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | ^14.13.1 \|\| >=16.0.0 |
| Dependencies | 1 |
| Unpacked size | 7.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Connor White |
| Maintainers | bconnorwhite |
| Keywords | remove, file, files, safe, without, try, catch, fs-safe, rm, del, delete, trash |

## Links

- npm: https://www.npmjs.com/package/remove-file-safe
- Repository: https://github.com/bconnorwhite/remove-file-safe
- Homepage: https://connorwhite.org/github/remove-file-safe
- Issues: https://github.com/bconnorwhite/remove-file-safe/issues
- npm.io page: https://npm.io/package/remove-file-safe

## Dependencies (1)

- [is-path-inside](https://npm.io/package/is-path-inside.md) ^4.0.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 3.0.0 (latest) — 2023-01-12
- 2.0.0 — 2021-06-08
- 1.0.1 — 2020-10-04
- 1.0.0 — 2020-10-04

## README

<!--BEGIN HEADER-->
<div id="top" align="center">
  <h1>remove-file-safe</h1>
  <a href="https://npmjs.com/package/remove-file-safe">
    <img alt="NPM" src="https://img.shields.io/npm/v/remove-file-safe.svg">
  </a>
  <a href="https://github.com/bconnorwhite/remove-file-safe">
    <img alt="TypeScript" src="https://img.shields.io/github/languages/top/bconnorwhite/remove-file-safe.svg">
  </a>
  <a href="https://coveralls.io/github/bconnorwhite/remove-file-safe?branch=master">
    <img alt="Coverage Status" src="https://img.shields.io/coveralls/github/bconnorwhite/remove-file-safe.svg?branch=master">
  </a>
</div>

<br />

<blockquote align="center">Remove files without try catch.</blockquote>

<br />

_If I should maintain this repo, please ⭐️_
<a href="https://github.com/bconnorwhite/remove-file-safe">
  <img align="right" alt="GitHub stars" src="https://img.shields.io/github/stars/bconnorwhite/remove-file-safe?label=%E2%AD%90%EF%B8%8F&style=social">
</a>

_DM me on [Twitter](https://twitter.com/bconnorwhite) if you have questions or suggestions._
<a href="https://twitter.com/bconnorwhite">
  <img align="right" alt="Twitter" src="https://img.shields.io/twitter/url?label=%40bconnorwhite&style=social&url=https%3A%2F%2Ftwitter.com%2Fbconnorwhite">
</a>

---
<!--END HEADER-->

> 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.

## Installation

```sh
yarn add remove-file-safe
```

```sh
npm install remove-file-safe
```

```sh
pnpm add remove-file-safe
```

## Usage

```ts
import { removeFile, removeFileSync, Options } from "remove-file-safe";

function removeFile(path: string, options?: Options): Promise<boolean | undefined>;

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;
};
```
<!--BEGIN FOOTER-->

<br />

<h2 id="dependencies">Dependencies<a href="https://www.npmjs.com/package/remove-file-safe?activeTab=dependencies"><img align="right" alt="dependencies" src="https://img.shields.io/librariesio/release/npm/remove-file-safe.svg"></a></h2>

- [is-path-inside](https://www.npmjs.com/package/is-path-inside): Check if a path is inside another path

<br />

<h3>Dev Dependencies</h3>

- [@types/mock-fs](https://www.npmjs.com/package/@types/mock-fs): TypeScript definitions for mock-fs
- [@types/node](https://www.npmjs.com/package/@types/node): TypeScript definitions for Node.js
- [autorepo](https://www.npmjs.com/package/autorepo): Autorepo abstracts away your dev dependencies, providing a single command to run all of your scripts.
- [mock-fs](https://www.npmjs.com/package/mock-fs): A configurable mock file system.  You know, for testing.

<br />

<h2 id="license">License <a href="https://opensource.org/licenses/MIT"><img align="right" alt="license" src="https://img.shields.io/npm/l/remove-file-safe.svg"></a></h2>

[MIT](https://opensource.org/licenses/MIT)
<!--END FOOTER-->

<br />

## Related Packages

- [fs-safe](https://www.npmjs.com/package/fs-safe): A simple fs wrapper that doesn't throw
- [read-file-safe](https://www.npmjs.com/package/remove-file-safe): Read files without try catch
- [write-file-safe](https://www.npmjs.com/package/write-file-safe): Write files, and parent directories if necessary
- [read-dir-safe](https://www.npmjs.com/package/read-dir-safe): Read directories recursively or non-recursively
- [write-dir-safe](https://www.npmjs.com/package/write-dir-safe): Create directories and their parents recursively
- [remove-dir-safe](https://www.npmjs.com/package/remove-dir-safe): Remove directories recursively or non-recursively

---
_Source: https://npm.io/package/remove-file-safe · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
