git-dir-up

1.0.0 • Public • Published

git-dir-up

Package Version Build Status: Linux Coverage Status Downloads Status

Find the closest .git directory

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

Installation

npm install --save git-dir-up

Usage

/
└── Users
    └── luftywiranda
        └── foo
            ├── .git
            └── bar
                ├── baz
                └── example.js
// example.js
const gitDirUp = require('git-dir-up');
 
gitDirUp(__dirname).then(path => {
  console.log(path);
  //=> '/Users/luftywiranda/foo/.git'
});

API

gitDirUp([cwd])

Returns Promise<string> for the path of .git or null if no .git dir found.

cwd

Type: string
Default: process.cwd()

Directory to start from.

Related

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

License

MIT © Lufty Wiranda

Dependents (0)

Package Sidebar

Install

npm i git-dir-up

Weekly Downloads

7

Version

1.0.0

License

MIT

Last publish

Collaborators

  • luftywiranda13