Unleash awesomeness. Private packages, team management tools, and powerful integrations. Get started with npm Orgs »

git-root-dir

1.0.2 • Public • Published

git-root-dir

Package Version Downloads Status Build Status: Linux Coverage Status

Find the root directory of a git repository.

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

Installation

npm install --save git-root-dir

Usage

/
└── Users
    └── luftywiranda
        └── foo
            ├── .git
            └── bar
                ├── baz
                └── example.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
Default: process.cwd()

Directory to start from.

Related

  • git-dir-up – Find the closest .git directory
  • pkg-dir – Find the root directory of a Node.js project or npm package

License

MIT © Lufty Wiranda

install

npm i git-root-dir

Downloadsweekly downloads

71

version

1.0.2

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability