All Projects → jonschlinkert → parse-git-config

jonschlinkert / parse-git-config

Licence: MIT license
Parse `.git/config` into a JavaScript object. sync or async.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to parse-git-config

Gray Matter
Contributing Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Stars: ✭ 2,105 (+3727.27%)
Mutual labels:  config, parse, jonschlinkert
common-words
Updated list of the 100 most common words in the English language. Useful for excluding these words from arrays.
Stars: ✭ 13 (-76.36%)
Mutual labels:  parse, jonschlinkert
Remarkable
Markdown parser, done right. Commonmark support, extensions, syntax plugins, high speed - all in one. Gulp and metalsmith plugins available. Used by Facebook, Docusaurus and many others! Use https://github.com/breakdance/breakdance for HTML-to-markdown conversion. Use https://github.com/jonschlinkert/markdown-toc to generate a table of contents.
Stars: ✭ 5,252 (+9449.09%)
Mutual labels:  parse, jonschlinkert
remote-origin-url
Extract the git remote origin URL from your local git repository.
Stars: ✭ 15 (-72.73%)
Mutual labels:  config, gitconfig
snapdragon-lexer
Converts a string into an array of tokens, with useful methods for looking ahead and behind, capturing, matching, et cetera.
Stars: ✭ 19 (-65.45%)
Mutual labels:  parse, jonschlinkert
config-parser
A slim, fully managed C# library for reading/writing .ini, .conf, .cfg etc configuration files.
Stars: ✭ 67 (+21.82%)
Mutual labels:  config, conf
i3
Archivos de configuraciones de i3
Stars: ✭ 32 (-41.82%)
Mutual labels:  config, conf
libconfini
Yet another INI parser
Stars: ✭ 106 (+92.73%)
Mutual labels:  config, conf
eRCaGuy dotfiles
.bashrc file, terminal prompt that shows current git branch, Arduino setup, Eclipse setup, git diff with line numbers, helpful scripts, improved Linux productivity, etc.
Stars: ✭ 84 (+52.73%)
Mutual labels:  config, gitconfig
goconfig
.gitconfig syntax parser
Stars: ✭ 15 (-72.73%)
Mutual labels:  config, gitconfig
dotfiles
/home/yous
Stars: ✭ 43 (-21.82%)
Mutual labels:  config, gitconfig
read-env
🔧 Transform environment variables into JSON object with sanitized values.
Stars: ✭ 60 (+9.09%)
Mutual labels:  config, parse
javaproperties
Python library for reading & writing Java .properties files
Stars: ✭ 20 (-63.64%)
Mutual labels:  config
pfp-vim
A vim hex-editor plugin that uses 010 templates to parse binary data using pfp
Stars: ✭ 57 (+3.64%)
Mutual labels:  parse
dotfiles
🔧 My dotfiles on  macOS for Neovim, Zsh, kitty, lf, etc
Stars: ✭ 90 (+63.64%)
Mutual labels:  config
parse-server-test-runner
A tool for programmatically starting Parse Server
Stars: ✭ 18 (-67.27%)
Mutual labels:  parse
intuit-spring-cloud-config-inspector
Inspection of Spring Cloud Config properties made easy using React
Stars: ✭ 18 (-67.27%)
Mutual labels:  config
tomli
A lil' TOML parser
Stars: ✭ 313 (+469.09%)
Mutual labels:  config
pixl-xml
A simple module for parsing and composing XML.
Stars: ✭ 78 (+41.82%)
Mutual labels:  parse
logparser
Easy parsing of Apache HTTPD and NGINX access logs with Java, Hadoop, Hive, Pig, Flink, Beam, Storm, Drill, ...
Stars: ✭ 139 (+152.73%)
Mutual labels:  parse

parse-git-config NPM version NPM monthly downloads NPM total downloads Linux Build Status

Parse .git/config into a JavaScript object. sync or async.

Please consider following this project's author, Jon Schlinkert, and consider starring the project to show your ❤️ and support.

Install

Install with npm:

$ npm install --save parse-git-config

Usage

const parse = require('parse-git-config');

// sync
console.log(parse.sync());

// using async/await
(async () => console.log(await parse()))();

Options

cwd

The starting directory to search from.

Type: string

Default: process.cwd() (current working directory)

path

Either the absolute path to .git config, or the path relative to the current working directory.

Type: string

Default: .git/config

Examples config object

Parsed config object will look 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 with cwd or path, the cwd to use, or the callback function.
  • callback {Function}: callback function if the first argument is options or cwd.
  • returns {Object}

Example

parse((err, config) => {
  if (err) throw err;
  // do stuff with config
});

// or, using async/await
(async () => {
  console.log(await parse());
  console.log(await parse({ cwd: 'foo' }));
  console.log(await parse({ cwd: 'foo', path: 'some/.git/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 with cwd or path, or the cwd to use.
  • returns {Object}

Example

console.log(parse.sync());
console.log(parse.sync({ cwd: 'foo' }));
console.log(parse.sync({ cwd: 'foo', path: 'some/.git/config' }));

.expandKeys

Returns an object with only the properties that had ini-style keys converted to objects.

Params

  • config {Object}: The parsed git config object.
  • returns {Object}

Example

const config = parse.sync({ path: '/path/to/.gitconfig' });
const obj = parse.expandKeys(config);

.expandKeys examples

Converts ini-style keys into objects:

Example 1

const parse = require('parse-git-config');
const config = { 
  'foo "bar"': { doStuff: true },
  'foo "baz"': { doStuff: true } 
};

console.log(parse.expandKeys(config));

Results in:

{ 
  foo: { 
    bar: { doStuff: true }, 
    baz: { doStuff: true } 
  } 
}

Example 2

const parse = require('parse-git-config');
const 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.expandKeys(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
    }
  }
}

About

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Running Tests

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

$ npm install && npm test
Building docs

(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)

To generate the readme, run the following command:

$ npm install -g verbose/verb#dev verb-generate-readme && verb

Related projects

You might also be interested in these projects:

Contributors

Commits Contributor
66 jonschlinkert
4 doowb
1 daviwil
1 LexSwed
1 sam3d
1 suarasaur

Author

Jon Schlinkert

License

Copyright © 2018, Jon Schlinkert. Released under the MIT License.


This file was generated by verb-generate-readme, v0.8.0, on November 20, 2018.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].