# git-root-dir

> Find the root directory of a `git` repository

Latest version **1.0.2** (published 2018-01-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install git-root-dir
pnpm add git-root-dir
yarn add git-root-dir
bun add git-root-dir
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2018-01-13 |
| First published | 2018-01-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/git-root-dir) |
| Module format | CommonJS |
| Node | >=6 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Lufty Wiranda |
| Maintainers | luftywiranda13 |
| Keywords | .git, dir, directory, entry, file, find-up, find, findup, folder, git, look-up, look, match, parent, parents, path, resolve, root, search, up, walk, walking |

## Links

- npm: https://www.npmjs.com/package/git-root-dir
- Repository: https://github.com/luftywiranda13/git-root-dir
- Homepage: https://github.com/luftywiranda13/git-root-dir#readme
- Issues: https://github.com/luftywiranda13/git-root-dir/issues
- npm.io page: https://npm.io/package/git-root-dir

## Dependencies (1)

- [find-up](https://npm.io/package/find-up.md) ^2.1.0

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

- 1.0.2 (latest) — 2018-01-13
- 1.0.1 — 2018-01-12
- 1.0.0 — 2018-01-12

## README

# git-root-dir

[![Package Version](https://img.shields.io/npm/v/git-root-dir.svg?style=flat-square)](https://www.npmjs.com/package/git-root-dir)
[![Downloads Status](https://img.shields.io/npm/dm/git-root-dir.svg?style=flat-square)](https://npm-stat.com/charts.html?package=git-root-dir&from=2016-04-01)
[![Build Status: Linux](https://img.shields.io/travis/luftywiranda13/git-root-dir/master.svg?style=flat-square)](https://travis-ci.org/luftywiranda13/git-root-dir)
[![Coverage Status](https://img.shields.io/codecov/c/github/luftywiranda13/git-root-dir/master.svg?style=flat-square)](https://codecov.io/gh/luftywiranda13/git-root-dir)

Find the root directory of a `git` repository.

Useful for tools that need to know whether `git` is managing the things inside.

## Installation

```sh
npm install --save git-root-dir
```

## Usage

```sh
/
└── Users
    └── luftywiranda
        └── foo
            ├── .git
            └── bar
                ├── baz
                └── example.js
```

```js
// example.js
const gitRootDir = require('git-root-dir');

gitRootDir(__dirname).then(rootDir => {
  console.log(rootDir);
  //=> '/Users/luftywiranda/foo'
});
```

## API

### gitRootDir([cwd])

Returns a Promise for either the repository root path or null if it couldn't be found.

#### cwd

Type: `string`<br />
Default: `process.cwd()`

Directory to start from.

## Related

* [git-dir-up](https://github.com/luftywiranda13/git-dir-up) – Find the closest `.git` directory
* [pkg-dir](https://github.com/sindresorhus/pkg-dir) – Find the root directory of a Node.js project or npm package

## License

MIT &copy; [Lufty Wiranda](https://www.luftywiranda.com)

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