findRoot
Find the root git directory
param | type [= default] | description |
---|---|---|
fs | FsClient | a file system client |
filepath | string | The file directory to start searching in. |
return | Promise<string> | Resolves successfully with a root git directory path |
throws | Error | NotFoundError |
Starting at filepath
, walks upward until it finds a directory that contains a subdirectory called '.git'.
Example Code:
let gitroot = await git.findRoot({
fs,
filepath: '/tutorial/src/utils'
})
console.log(gitroot)
Tip: If you need a clean slate, expand and run this snippet to clean up the file system.
window.fs = new LightningFS('fs', { wipe: true })
window.pfs = window.fs.promises
console.log('done')