git-local-info-ts
Version:
Retrieve current sha, branch name, repository from a git repo.
61 lines (40 loc) • 1.15 kB
Markdown
> Fork of <https://github.com/ycjcl868/git-local-info>
[](https://www.npmjs.org/package/git-local-info-ts)
--------------------
Retrieves repo information without relying on the `git` command.
[](https://npmjs.org/package/git-local-info-ts)
```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',
}
```
