remove-file-safe

Remove files without try catch

Usage no npm install needed!

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

README

remove-file-safe

NPM TypeScript Coverage Status GitHub Stars Twitter Follow

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

yarn add remove-file-safe
npm install remove-file-safe

API

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;
};

Dependenciesdependencies


Dev DependenciesDavid


License license

MIT


Related Packages