@dada78641/repo-version
v0.1.2
Published
Retrieves versioning information from a .git directory
Downloads
160
Readme
@dada78641/repo-version
repo-version is a simple and lightweight library designed to retrieve versioning information from a Git repository.
It extracts data directly from the .git directory without spawning a subprocess.
Usage
npm i @dada78641/repo-version
import {getGitRepoInfo, type GitRepoInfo} from '@dada78641/repo-version'
// should have .git directory inside
const repoInfo: GitRepoInfo = await getGitRepoInfo('/path/to/my/project')
console.log(repoInfo)
// logs:
//
// {
// branch: 'develop',
// branchRef: 'refs/heads/develop',
// hash: 'd59e60e50b13091cb86e8d267419820883cabc02',
// shortHash: 'd59e60e',
// commits: 3
// }
If a .git directory is not found or invalid, getGitRepoInfo() will throw an error.
License
MIT licensed.