Check if a file exists without try catch
npm install file-exists-safeCheck if a file exists without try catch.
_If I should maintain this repo, please ⭐️_
_DM me on Twitter if you have questions or suggestions._
---
> 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.
``sh`
yarn add file-exists-safe
`sh`
npm install file-exists-safe
`sh`
pnpm add file-exists-safe
`ts
import { fileExists, fileExistsSync, Options } from "file-exists-safe";
function fileExists(path: string, options?: Options): Promise
function fileExistsSync(path: string, options?: Options): boolean | undefined;
type Options = {
/**
* Return true if path is directory. Default: false``
*/
includeDirectories?: boolean;
};
- @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
- dir-exists-safe: Check if a directory exists without a try catch