file-exists-safe
Check if a file exists without try catch
Last updated 2 years ago by bconnorwhite .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install file-exists-safe 
SYNC missed versions from official npm registry.

file-exists-safe

NPM TypeScript Coverage Status

Check if a file exists without try catch.

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

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


Check if a file exists without try catch.

  • Returns true if the path exists and is a file.
  • Returns false if the path is not a file, or does not exist.
  • Returns undefined on other errors (for example, permission denied) rather than throwing.

Installation

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

Usage

import { fileExists, fileExistsSync, Options } from "file-exists-safe";

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

function fileExistsSync(path: string, options?: Options): boolean | undefined;

type Options = {
  /**
   * Return true if path is directory. Default: `false`
   */
  includeDirectories?: boolean;
};

Dev Dependencies

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

License license

MIT


Related Packages

  • fs-safe: A simple fs wrapper that doesn't throw
  • dir-exists-safe: Check if a directory exists without a try catch

Current Tags

  • 2.0.0                                ...           latest (2 years ago)

5 Versions

  • 2.0.0                                ...           2 years ago
  • 1.1.0                                ...           4 years ago
  • 1.0.2                                ...           4 years ago
  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Downloads
Today 0
This Week 0
This Month 3
Last Day 0
Last Week 3
Last Month 0
Dependencies (0)
None
Dev Dependencies (4)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |