1.0.0 • Published 3 years ago

find-gitdir v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
3 years ago

find-gitdir

Find .git directory with support of submodules and --separate-git-dir.

npm status node Test JavaScript Style Guide

Usage

const gitdir = require('find-gitdir')

Let's say we have a git repository at /example and that this is our working directory. Its gitdir will commonly be at /example/.git.

await gitdir() // /example/.git

Let's also say we have a git submodule at ./beep. Then find-gitdir will find a symbolic link at ./beep/.git pointing to the gitdir ../.git/modules/beep:

await gitdir('./beep') // /example/.git/modules/beep

By default find-gitdir does not look in parent directories. It can be enabled:

await gitdir('./node_modules/find-gitdir')       // null
await gitdir('./node_modules/find-gitdir', true) // /example/.git

API

gitdir([cwd][, roam][, callback])

Yields an absolute path to a .git directory or null if not found, given working directory cwd which defaults to process.cwd(). Set roam to true to enable looking in parent directories. If no callback if provided, a promise is returned.

gitdir.sync([cwd][, roam])

Synchronous variant. Returns an absolute path or null.

Install

With npm do:

npm install find-gitdir

License

MIT © Vincent Weevers