This utility helps you find the root directory of a project from any subdirectory within it. It searches for .git by default, but you can customize the search criteria.
Supposing you have the following project structure:
/foo/bar/project/
- src/
- components/
- handlers/
- tools.ts
- .git/
- package.json
And in tools.ts:
import * as rd from 'jsr:@timepp/rootdir'
...
const rootDir = rd.findRootDir()
// rootDir will be '/foo/bar/project'