# find-parent-dir

> Finds the first parent directory that contains a given file or directory.

Latest version **0.3.1** (published 2021-05-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install find-parent-dir
pnpm add find-parent-dir
yarn add find-parent-dir
bun add find-parent-dir
```

## Health

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

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.1 |
| Published | 2021-05-14 |
| First published | 2013-05-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/find-parent-dir) |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 24 |
| Author | Thorsten Lorenz |
| Maintainers | thlorenz |
| Keywords | find, parent, dir, root, resolve, walk |

## Links

- npm: https://www.npmjs.com/package/find-parent-dir
- Repository: https://github.com/thlorenz/find-parent-dir
- Issues: https://github.com/thlorenz/find-parent-dir/issues
- npm.io page: https://npm.io/package/find-parent-dir

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 0.3.1 (latest) — 2021-05-14
- 0.3.0 — 2014-03-29
- 0.2.1 — 2014-02-03
- 0.2.0 — 2014-01-27
- 0.1.0 — 2013-05-25

## README

# find-parent-dir [![build status](https://secure.travis-ci.org/thlorenz/find-parent-dir.png)](http://travis-ci.org/thlorenz/find-parent-dir)

Finds the first parent directory that contains a given file or directory.

    npm install find-parent-dir

```js
// assuming this is called from a file in a subdirectory of /myprojects/foo which contains .git directory
var findParentDir = require('find-parent-dir');

findParentDir(__dirname, '.git', function (err, dir) {
  // has err if some file access error occurred
  console.log(dir); // => /myprojects/foo/
  
  // if parent dir wasn't found, dir is null
})

// Same using `sync` method
var dir;
try { 
  dir = findParentDir.sync(__dirname, '.git');
  console.log(dir); // => /myprojects/foo/
  // if parent dir wasn't found, dir is null
} catch(err) {
  console.error('error', err); 
}
```

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