Resolves and returns git config as an object
$ npm install --save gitfig
const gitFig = require('gitfig');
gitFig();
//=> {name: 'Alexey Lizurchik', email: '[email protected]'}
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);
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
Synchronous version (with the same lookup behaviour) which returns value rather then promise. Throws an error if git config is not found.
MIT © Alexey Lizurchik