JSPM

@simbo/is-git-repository-root

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 8
  • Score
    100M100P100Q36210F
  • License MIT

A lightweight utility for checking whether a directory is the root of a Git repository.

Package Exports

  • @simbo/is-git-repository-root

Readme

Is Git Repository Root

📦 @simbo/is-git-repository-root

A lightweight utility for checking whether a directory is the root of a Git repository.

It simply checks for the presence of a .git folder in the given directory.

Features

  • Detects if a directory is the root of a Git repository

  • Defaults to checking the current working directory

  • Async and Promise-based API

  • Fully typed with TypeScript

  • Zero dependencies (besides other @simbo/* packages)

⚠️ Git submodules and worktrees are not considered repository roots.

Installation

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

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

Usage

For a complete API reference, see the documentation.

Example

import { isGitRepositoryRoot } from '@simbo/is-git-repository-root';

if (await isGitRepositoryRoot()) {
  console.log('This is a Git repository root.');
}

if (await isGitRepositoryRoot('/path/to/dir')) {
  console.log('That directory is a Git repository root.');
}

License

MIT © Simon Lepel