UNPKG

@wroud/git

Version:

A lightweight toolset for working with local git, including utilities for retrieving git commits and tags, ideal for CI/CD pipelines and automated release workflows.

21 lines (18 loc) 537 B
import { execa } from "execa"; /** * Validates that Git is installed and the current directory is a Git repository. */ export async function validateGitEnvironment() { try { // Check if Git is installed await execa`git --version`; } catch { throw new Error("Git is not installed or not found in PATH."); } try { // Check if the current directory is a Git repository await execa`git rev-parse --is-inside-work-tree`; } catch { throw new Error("The current directory is not a Git repository."); } }