A simple way to extract out all the contents of a .gitconfig file and return as JSON
This module is installed via npm:
$ npm install git-config
var gitConfig = require('git-config');
gitConfig(function (err, config) {
if (err) return done(err);
expect(config.user.name).to.equal('Eugene Ware');
expect(config.user.email).to.equal('eugene@noblesamurai.com');
expect(config.github.user).to.equal('eugeneware');
done();
});
Explicitly give a gitconfig file:
var gitConfig = require('git-config');
gitConfig('/my/path/.gitconfig1', function (err, config) {
if (err) return done(err);
expect(config.user.name).to.equal('Eugene Ware');
expect(config.user.email).to.equal('eugene@noblesamurai.com');
expect(config.github.user).to.equal('eugeneware');
done();
});
var gitConfig = require('git-config');
var config = gitConfig.sync(); // can pass explit file if you want as well