You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
3.1 KiB
Markdown

# parse-git-config [![NPM version](https://img.shields.io/npm/v/parse-git-config.svg)](https://www.npmjs.com/package/parse-git-config) [![Build Status](https://img.shields.io/travis/jonschlinkert/parse-git-config.svg)](https://travis-ci.org/jonschlinkert/parse-git-config)
10 years ago
> Parse `.git/config` into a JavaScript object. sync or async.
## Install
10 years ago
Install with [npm](https://www.npmjs.com/):
```sh
$ npm install parse-git-config --save
10 years ago
```
## Usage
```js
var git = require('parse-git-config');
// sync
var config = git.sync();
// or async
git(function (err, config) {
// do stuff with err/config
});
```
**Custom path and/or cwd**
```js
git.sync({cwd: 'foo', path: '.git/config'});
// async
git({cwd: 'foo', path: '.git/config'}, function (err, config) {
// do stuff
});
```
**Example result**
10 years ago
Config object will be something like:
```js
{ 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', ... } }
```
## Related projects
* [parse-author](https://www.npmjs.com/package/parse-author): Parse a string into an object with `name`, `email` and `url` properties following npm conventions.… [more](https://www.npmjs.com/package/parse-author) | [homepage](https://github.com/jonschlinkert/parse-author)
* [parse-authors](https://www.npmjs.com/package/parse-authors): Parse a string into an array of objects with `name`, `email` and `url` properties following… [more](https://www.npmjs.com/package/parse-authors) | [homepage](https://github.com/jonschlinkert/parse-authors)
* [parse-github-url](https://www.npmjs.com/package/parse-github-url): Parse a github URL into an object. | [homepage](https://github.com/jonschlinkert/parse-github-url)
* [parse-gitignore](https://www.npmjs.com/package/parse-gitignore): Parse a gitignore file into an array of patterns. Comments and empty lines are stripped. | [homepage](https://github.com/jonschlinkert/parse-gitignore)
## Contributing
10 years ago
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/parse-git-config/issues/new).
10 years ago
## Building docs
10 years ago
Generate readme and API documentation with [verb](https://github.com/verbose/verb):
```sh
$ npm install verb && npm run docs
10 years ago
```
Or, if [verb](https://github.com/verbose/verb) is installed globally:
```sh
$ verb
```
## Running tests
Install dev dependencies:
```sh
$ npm install -d && npm test
```
10 years ago
## Author
**Jon Schlinkert**
* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
10 years ago
## License
Copyright © 2016 [Jon Schlinkert](https://github.com/jonschlinkert)
Released under the [MIT license](https://github.com/jonschlinkert/parse-git-config/blob/master/LICENSE).
10 years ago
***
_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on February 26, 2016._