git-dir-up
v1.0.0
Published
Find the closest `.git` directory
Downloads
13
Maintainers
Readme
git-dir-up
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