Documentation for Simbo's Packages
    Preparing search index...

    Module @simbo/find-git-repository-root - v1.0.2

    Find Git Repository Root

    📦 @simbo/find-git-repository-root

    A lightweight utility for locating the root directory of a Git repository.

    It searches upward from a given directory until it finds a valid repository root (a directory containing a .git folder).

    This package builds on find-up and @simbo/is-git-repository-root.

    • Detects the root directory of a Git repository

    • Returns the absolute path to the Git repository root

    • Uses upward search from a given working directory (defaults to process.cwd())

    • Async and Promise-based API

    • Fully typed with TypeScript

    Install @simbo/find-git-repository-root from the npm registry:

    npm i [-D] @simbo/find-git-repository-root
    

    For a complete API reference, see the documentation.

    import { findGitRepositoryRoot } from '@simbo/find-git-repository-root';

    // Default: start from current working directory
    const root = await findGitRepositoryRoot();

    // Or specify a starting directory
    const rootFromPath = await findGitRepositoryRoot('/path/to/subdir');

    If no Git repository root is found, the function resolves to undefined.

    MIT © Simon Lepel

    Functions

    findGitRepositoryRoot