Git Product home page Git Product logo

read-git-user's Introduction

read-git-user build

Reads the Github username and email from .gitconfig 🔧 and returns it as a json object

Highlights

  • Tiny(1.3kB ✨) and simple
  • Returns the original github-username since the stored git name can be altered and not reliable.
  • Uses Ini to handle the parsing of the ini config file

Install

npm install read-git-user

Usage

import readGitUser = require('read-git-user');

(async () => {
        const gitUser = await readGitUser();
        //=> {username: RocktimsSaikia, email: [email protected]}
})();

API

readGitUser(options?)

Returns a Promise<object> with the parsed JSON.

options

dir

Type: string
Default: os.homedir()

The directory of the .gitconfig file

License

MIT © Rocktim Saikia

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

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

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.

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.