An open API service indexing awesome lists of open source software.

https://github.com/rocktimsaikia/read-git-user

Returns the GitHub username and email of the current system's .gitconfig
https://github.com/rocktimsaikia/read-git-user

gitconfig github github-user

Last synced: 5 months ago
JSON representation

Returns the GitHub username and email of the current system's .gitconfig

Awesome Lists containing this project

README

          

# read-git-user

Returns the GitHub username and email of the current system's `.gitconfig`.

> [!NOTE]
> This function retrieves the original GitHub username since the stored \
> git config name is not reliable. The local name can be changed without \
> affecting any Git or GitHub activities as long as the email matches any \
> verified emails on the GitHub account.

[![Tests](https://github.com/rocktimsaikia/read-git-user/actions/workflows/main.yml/badge.svg)](https://github.com/rocktimsaikia/read-git-user/actions/workflows/main.yml) [![npm](https://img.shields.io/npm/v/read-git-user?color=bright)](https://npmjs.com/package/read-git-user)

## Install

```bash
npm i read-git-user
```

## Usage

```js
import readGitUser from "read-git-user";

const gitUser = await readGitUser();

console.log(gitUser);
// => {username: rocktimssaikia, email: rocktimthedev@gmail.com}
```

## API

### readGitUser(options)

Returns a `Promise` with the retrieved git config data.

#### Options (`object`) :

##### `dir`

> Type: `string`

> Default: `os.homedir()`
>
> The directory of the `.gitconfig` file. \
> This option is available in-case the config file is not in the default dir for some systems.