Package Exports
- parse-git-config
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (parse-git-config) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
parse-git-config

Parse
.git/configinto a JavaScript object. sync or async.
Install
Install with npm:
$ npm install parse-git-config --saveUsage
var parse = require('parse-git-config');
// sync
var config = parse.sync();
// or async
parse(function (err, config) {
// do stuff with err/config
});Custom path and/or cwd
parse.sync({cwd: 'foo', path: '.git/config'});
// async
parse({cwd: 'foo', path: '.git/config'}, function (err, config) {
// do stuff
});Example result
Config object will be something like:
{ core:
{ repositoryformatversion: '0',
filemode: true,
bare: false,
logallrefupdates: true,
ignorecase: true,
precomposeunicode: true },
'remote "origin"':
{ url: 'https://github.com/jonschlinkert/parse-git-config.git',
fetch: '+refs/heads/*:refs/remotes/origin/*' },
'branch "master"': { remote: 'origin', merge: 'refs/heads/master', ... } }API
parse
Asynchronously parse a .git/config file. If only the callback is passed, the .git/config file relative to process.cwd() is used.
Params
options{Object|String|Function}: Options withcwdorpath, the cwd to use, or the callback function.cb{Function}: callback function if the first argument is options or cwd.returns{Object}
Example
parse(function(err, config) {
if (err) throw err;
// do stuff with config
});.sync
Synchronously parse a .git/config file. If no arguments are passed, the .git/config file relative to process.cwd() is used.
Params
options{Object|String}: Options withcwdorpath, or the cwd to use.returns{Object}
Example
var config = parse.sync();.keys
Returns an object with only the properties that had ini-style keys converted to objects (example below).
Params
config{Object}: The parsed git config object.returns{Object}
Example
var config = parse.sync();
var obj = parse.keys(config);.keys examples
Converts ini-style keys into objects:
Example 1
var parse = require('parse-git-config');
var config = {
'foo "bar"': { doStuff: true },
'foo "baz"': { doStuff: true }
};
console.log(parse.keys(config));Results in:
{
foo: {
bar: { doStuff: true },
baz: { doStuff: true }
}
}Example 2
var parse = require('parse-git-config');
var config = {
'remote "origin"': {
url: 'https://github.com/jonschlinkert/normalize-pkg.git',
fetch: '+refs/heads/*:refs/remotes/origin/*'
},
'branch "master"': {
remote: 'origin',
merge: 'refs/heads/master'
},
'branch "dev"': {
remote: 'origin',
merge: 'refs/heads/dev',
rebase: true
}
};
console.log(parse.keys(config));Results in:
{
remote: {
origin: {
url: 'https://github.com/jonschlinkert/normalize-pkg.git',
fetch: '+refs/heads/*:refs/remotes/origin/*'
}
},
branch: {
master: {
remote: 'origin',
merge: 'refs/heads/master'
},
dev: {
remote: 'origin',
merge: 'refs/heads/dev',
rebase: true
}
}
}Related projects
- git-user-name: Get a user's name from git config at the project or global scope, depending on… more | homepage
- git-username: Get the username from a git remote origin URL. | homepage
- parse-author: Parse a string into an object with
name,emailandurlproperties following npm conventions.… more | homepage - parse-authors: Parse a string into an array of objects with
name,emailandurlproperties following… more | homepage - parse-github-url: Parse a github URL into an object. | homepage
- parse-gitignore: Parse a gitignore file into an array of patterns. Comments and empty lines are stripped. | homepage
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Building docs
Generate readme and API documentation with verb:
$ npm install verb && npm run docsOr, if verb is installed globally:
$ verbRunning tests
Install dev dependencies:
$ npm install -d && npm testAuthor
Jon Schlinkert
License
Copyright © 2016 Jon Schlinkert Released under the MIT license.
This file was generated by verb, v0.9.0, on March 19, 2016.