Giter Club home page Giter Club logo

read-git-user's Introduction

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 npm

Install

npm i read-git-user

Usage

import readGitUser from "read-git-user";

const gitUser = await readGitUser();

console.log(gitUser);
// => {username: rocktimssaikia, email: [email protected]}

API

readGitUser(options)

Returns a Promise<object> 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.

read-git-user's People

Contributors

ozum avatar rocktimsaikia avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

ozum

read-git-user's Issues

run a `exec` command as a fallback function.

Currently, we are navigating to the system's homeDir and extracting the git user details from there. But still, there is a chance of running into some errors while doing so, it may also work differently in different OSS.

So as a fallback function it would be nice to implement an exec run command to read the git user details right from the stdout.Exec based libs like shelljs or execa with good error handling support can be used for this feature.

Cannot find module 'xo' or its corresponding type declarations.

Hi,

When used with typescript (v3 and v4), I got following error:

node_modules/read-git-user/index.d.ts:1:23 - error TS2307: Cannot find module 'xo' or its corresponding type declarations.

1 import {Options} from 'xo';
                        ~~~~

Also it seems, xo is not used here. Removing this line corrects the error.

Thanks,

Remove the `dir` option.

The whole point of this module is getting the username with automation and zero config. Having a dir option to point to a .gitconfig file is completely opposite and redundant.

read the username using the system email address

The username stored in the system is not very reliable and can be altered anytime and it won't even affect the git cli experience as the authentication process only cares about the email.

No, your user.name does not matter.
However, your user.email should match one of the addresses in your GitHub settings.

https://stackoverflow.com/a/28142874/9360234

So we should read the online Github username by using the existing system email address.
This can be easily achieved with a module like Github-username

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.