gitfig
v1.0.2
Published
Resolves and returns git config as an object
Downloads
17
Maintainers
Readme
Git(con)fig
Resolves and returns git config as an object
Install
$ npm install --save gitfig
Usage
const gitFig = require('gitfig');
gitFig();
//=> {name: 'Alexey Lizurchik', email: 'al.lizurchik@gmail.com'}
API
gitfig([@type|path])
@type
Possible values are 0 and 2. Can be accessed throw the constants in exported object: LOCAL
, HOME
.
Example:
const gitFig = require('gitfig');
console.log(gitFig.LOCAL);
console.log(gitFig.HOME);
path
Type: string
Path for looking git config for. Works for both git repos (you don't need to add .git
in path) and (custom) home path.
Asynchronously looks up for git config by cascade:
- The local config is looked for
- The home config is looked for
Returns promise which rejects if git config is not found.
Alternatively you can specify concrete place of look up:
const gitFig = require('gitfig');
gitFig(); // cascade
gitFig(gitFig.LOCAL); // current working directory (from where script is called)
gitFig(gitFig.HOME); // current user's home path
gitFig('/var/www/mysite'); // looks for /var/www/mysite/.git/config or if failed - /var/www/mysite/.gitconfig
gitfig.sync(@type)
Synchronous version (with the same lookup behaviour) which returns value rather then promise. Throws an error if git config is not found.
License
MIT © Alexey Lizurchik