0.1.2 • Published 5 years ago
git-head-info v0.1.2
git-head-info ·
Retrieve current sha and branch name from a git repo.
Install
npm i git-head-info
Usage
import gitHeadInfo from 'git-head-info' /* or */ const gitHeadInfo = require('git-head-info')
/**
* @param {path | void} repo: the git repo to get HEAD info, default is current working dir
* @returns ({
* repo: the repo used to get git info
* sha: HEAD sha
* branch: HEAD branch | undefined(if in `detached HEAD` state)
* })
*/
// promise
gitHeadInfo(repo?).then(res => {
...
}).catch()
// async
async function foo() {
try {
const res = await gitHeadInfo(repo?)
...
} catch() {}
}