# dir-exists-safe

> Check if a directory exists without try catch

Latest version **1.1.0** (published 2021-04-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install dir-exists-safe
pnpm add dir-exists-safe
yarn add dir-exists-safe
bun add dir-exists-safe
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2021-04-13 |
| First published | 2020-10-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Connor White |
| Maintainers | bconnorwhite |
| Keywords | dir, directory, file, folder, exists, exist, check, if, safe, without, try, catch, fs-safe |

## Links

- npm: https://www.npmjs.com/package/dir-exists-safe
- Repository: https://github.com/bconnorwhite/dir-exists-safe
- Homepage: https://connorwhite.org/github/dir-exists-safe
- npm.io page: https://npm.io/package/dir-exists-safe

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 1.1.0 (latest) — 2021-04-13
- 1.0.1 — 2020-10-04
- 1.0.0 — 2020-10-03

## README

<div align="center">
  <a href="https://github.com/bconnorwhite/dir-exists-safe">
    <img alt="dir-exists-safe" src="assets/header.svg" />
  </a>
  <a href="https://npmjs.com/package/dir-exists-safe">
    <img alt="NPM" src="https://img.shields.io/npm/v/dir-exists-safe.svg">
  </a>
  <a href="https://github.com/bconnorwhite/dir-exists-safe">
    <img alt="TypeScript" src="https://img.shields.io/github/languages/top/bconnorwhite/dir-exists-safe.svg">
  </a>
  <a href='https://coveralls.io/github/bconnorwhite/dir-exists-safe?branch=master'>
    <img alt="Coverage Status" src="https://img.shields.io/coveralls/github/bconnorwhite/dir-exists-safe.svg?branch=master">
  </a>
  <a href="https://github.com/bconnorwhite/dir-exists-safe">
    <img alt="GitHub Stars" src="https://img.shields.io/github/stars/bconnorwhite/dir-exists-safe?label=Stars%20Appreciated%21&style=social">
  </a>
  <a href="https://twitter.com/bconnorwhite">
    <img alt="Twitter Follow" src="https://img.shields.io/twitter/follow/bconnorwhite.svg?label=%40bconnorwhite&style=social">
  </a>
</div>

<br />

> Check if a directory exists without try catch.

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

## Installation

```sh
yarn add dir-exists-safe
```

```sh
npm install dir-exists-safe
```

## API

```ts
import { dirExists, dirExistsSync, Options } from "dir-exists-safe";

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

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

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

<br />

<h2>Dev Dependencies<img align="right" alt="David" src="https://img.shields.io/david/dev/bconnorwhite/dir-exists-safe.svg"></h2>

- [@bconnorwhite/bob](https://www.npmjs.com/package/@bconnorwhite/bob): Bob is a toolkit for typescript projects
- [@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
- [mock-fs](https://www.npmjs.com/package/mock-fs): A configurable mock file system.  You know, for testing.

<br />

<h2>License <img align="right" alt="license" src="https://img.shields.io/npm/l/dir-exists-safe.svg"></h2>

[MIT](https://opensource.org/licenses/MIT)

<br />

## Related Packages

- [fs-safe](https://www.npmjs.com/package/fs-safe): A simple fs wrapper that doesn't throw
- [file-exists-safe](https://www.npmjs.com/package/file-exists-safe): Check if a file exists without a try catch

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