git-head-info
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

git-head-info · GitHub npm CircleCI branch

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() {}
}

Readme

Keywords

Package Sidebar

Install

npm i git-head-info

Weekly Downloads

4

Version

0.1.2

License

MIT

Unpacked Size

6.44 kB

Total Files

9

Last publish

Collaborators

  • ongw20