# directory-exists

> Check to see if a directory exists

Latest version **2.0.1** (published 2018-09-18) · Unlicense license · 0 weekly downloads

## Install

```sh
npm install directory-exists
pnpm add directory-exists
yarn add directory-exists
bun add directory-exists
```

## 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 | 2.0.1 |
| Published | 2018-09-18 |
| First published | 2016-07-11 |
| Weekly downloads | 0 |
| License | Unlicense |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | timmydoza |
| Maintainers | timmydoza |
| Keywords | check, dir, dirs, directories, directory, exist, exists, file, filepath, files, folder, fp, fs, node, node.js, path, paths, system |

## Links

- npm: https://www.npmjs.com/package/directory-exists
- Repository: https://github.com/timmydoza/directory-exists
- Homepage: https://github.com/timmydoza/directory-exists#readme
- Issues: https://github.com/timmydoza/directory-exists/issues
- npm.io page: https://npm.io/package/directory-exists

## 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

- 2.0.1 (latest) — 2018-09-18
- 2.0.0 — 2018-03-30
- 1.0.2 — 2017-06-09
- 1.0.1 — 2016-07-12
- 1.0.0 — 2016-07-11
- 0.0.1 — 2016-07-11

## README

# directory-exists [![Build Status](https://travis-ci.org/timmydoza/directory-exists.svg?branch=master)](https://travis-ci.org/timmydoza/directory-exists)

> Check if a directory exists - synchronously or asynchronously

## Install

```
$ npm install --save directory-exists
```

## Usage:
`directory` should be a string of a relative or absolute path.

### Asynchronous

##### With Callback:

```js
const directoryExists = require('directory-exists');

directoryExists(directory, (error, result) => {
  console.log(result); // result is a boolean
});
```

##### With Promise:
If no callback function is supplied, directoryExists returns a promise.

```js
const directoryExists = require('directory-exists');

directoryExists(directory).then(result => {
  console.log(result); // result is a boolean
});
```

##### Async/await:

```js
const directoryExists = require('directory-exists');

(async function() {
  const result = await directoryExists(directory);
  console.log(result);  // result is a boolean
})();
```

### Synchronous

```js
const directoryExists = require('directory-exists');

directoryExists.sync(directory); // retuns a boolean
```

## Why not use `fs.exists`?
Because asynchronous `fs.exists` is [deprecated](https://nodejs.org/api/fs.html#fs_fs_exists_path_callback). Synchronous `fs.existsSync` is still [fine](https://nodejs.org/api/fs.html#fs_fs_existssync_path) to use, but this library does both sync and async.

## License

MIT © timmydoza

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