findRoot
Find the root git directory
| param | type [= default] | description |
|---|---|---|
| core | string = 'default' | The plugin core identifier to use for plugin injection |
| fs [deprecated] | FileSystem | The filesystem containing the git repo. Overrides the fs provided by the plugin system. |
| filepath | string | The file directory to start searching in. |
| return | Promise<string> | Resolves successfully with a root git directory path |
| throws | Error | GitRootNotFoundError |
Starting at filepath, walks upward until it finds a directory that contains a subdirectory called '.git'.
Example Code:
let gitroot = await git.findRoot({
filepath: '$input((/path/to/some/gitrepo/path/to/some/file.txt))'
})
console.log(gitroot) // '/path/to/some/gitrepo'