file-exists-safe
v3.0.0
Published
Check if a file exists without try catch
Maintainers
Readme
- Returns
trueif the path exists and is a file. - Returns
falseif the path is not a file, or does not exist. - Returns
undefinedon other errors, such as permission denied, rather than throwing.
Installation
npm install file-exists-safeyarn add file-exists-safepnpm add file-exists-safebun add file-exists-safeUsage
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;
};MIT - MIT License
Related Packages
- fs-safe: A simple fs wrapper that doesn't throw
- dir-exists-safe: Check if a directory exists without a try catch
