git-local-info
Version:
Retrieve current sha, branch name, repository from a git repo.
63 lines (42 loc) • 1.29 kB
Markdown
//img.shields.io/npm/v/git-local-info.svg?style=flat-square)](https://www.npmjs.org/package/git-local-info) [](https://travis-ci.org/ycjcl868/git-local-info) [](https://david-dm.org/ycjcl868/git-local-info)
--------------------
Retrieves repo information without relying on the `git` command.
```
// install
$ npm install git-local-info -S
```
```javascript
import GitInfo from 'git-local-info';
const gitInfo = new GitInfo();
const result = gitInfo.getGitInfo;
// result is:
{
/** The current branch */
branch: string;
/** The current repository url */
repository: string;
/** SHA of the current commit */
sha: string;
/** The committer of the current SHA */
commit: ICommit;
/** The commit message for the current SHA */
rootDir: string;
}
```
new GitInfo(params);
```js
// params
{
// default process.cwd()
gitPath: process.cwd(),
// default .git
GIT_DIR: '.git',
}
```

[![npm package](https: