Walk the parent chain from startPath and locate project markers:
.git, package.json, tsconfig.json, and node_modules/. For each
marker the result contains nearest* (first hit walking up) and root*
(last hit, bounded by the enclosing .git). Also reports gitRoot
(innermost, matching git rev-parse --show-toplevel) and gitSuperRoot
(outermost .git directory when nested in a submodule or worktree,
otherwise null).
The walk stops at the filesystem root, at the user's home directory (or
any ancestor of it), at stopPath (same rule — if provided), and at a
depth cap of 128 (symlink-loop defense).
Tolerant of missing paths and mid-walk stat errors — missing fields are
returned as null rather than throwing. If startPath doesn't exist, the
walk begins from its longest existing ancestor.
Runs asynchronously on the compute thread pool.
Parameters
startPath: string
Starting path — may be a file or a directory.
OptionalstopPath: string
Optional directory — if the walker reaches this path (or
any strict ancestor of it), the walk stops without probing.
Walk the parent chain from
startPathand locate project markers:.git,package.json,tsconfig.json, andnode_modules/. For each marker the result containsnearest*(first hit walking up) androot*(last hit, bounded by the enclosing.git). Also reportsgitRoot(innermost, matchinggit rev-parse --show-toplevel) andgitSuperRoot(outermost.gitdirectory when nested in a submodule or worktree, otherwisenull).The walk stops at the filesystem root, at the user's home directory (or any ancestor of it), at
stopPath(same rule — if provided), and at a depth cap of 128 (symlink-loop defense).Tolerant of missing paths and mid-walk stat errors — missing fields are returned as
nullrather than throwing. IfstartPathdoesn't exist, the walk begins from its longest existing ancestor.Runs asynchronously on the compute thread pool.