0.1.2 • Published 10 months ago

@dada78641/repo-version v0.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

TypeScript MIT license npm version

@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.

0.1.2

10 months ago

0.1.1

10 months ago

0.1.0

10 months ago