DEV Community

Rocktim Saikia
Rocktim Saikia

Posted on

✨ module to read git user config from the system and return it as a JSON object.

GitHub logo rocktimsaikia / read-git-user

Reads the username and email from `.gitconfig` and returns it as json object

Read-git-user is a tiny 1.3kB✨ module that can be used to retrieve the git username and email right from the systems global .gitconfig file.

How this works is that the module looks for HOME || USERPROFILE and reads the ini file from there and returns it as a parsed JSON object.


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

(async () => {
        const gitUser = await readGitUser();
        //=> {user: rocktimsaikia, email:}

        const gitUser = readGitUser.sync()
        //=> {user: rocktimsaikia, email:}
Enter fullscreen mode Exit fullscreen mode

[ PS: I created this tool to use it in a project that I am working on. I thought someone might find it handy so made a quick post. Leave a star at the repo 🌟 if find this helpful. Thanks for reading 👋]

Top comments (0)