
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
parse-git-config
Advanced tools
The parse-git-config npm package is a utility for parsing git configuration files. It allows developers to read and interpret the configuration settings of git repositories programmatically. This can be useful for automating tasks, creating development tools, or integrating with other software that needs to understand git configurations.
Parse local git configuration
This feature allows you to parse the git configuration file of a local repository. The function takes options specifying the working directory and the path to the git config file, then returns the configuration as an object.
const parseGitConfig = require('parse-git-config');
parseGitConfig({ cwd: '/path/to/repo', path: '.git/config' }, (err, config) => {
if (err) throw err;
console.log(config);
});
Synchronously parse git config
This feature provides a synchronous method to parse the git config file. It is useful when you need to get the configuration data immediately without dealing with asynchronous callbacks.
const parseGitConfig = require('parse-git-config');
const config = parseGitConfig.sync({ cwd: '/path/to/repo', path: '.git/config' });
console.log(config);
Expand include paths
This feature supports expanding include directives in git config files, allowing you to see the full configuration with included paths resolved. This is particularly useful for complex configurations that use multiple included files.
const parseGitConfig = require('parse-git-config');
parseGitConfig.expandKeys({ include: true }).then(config => {
console.log(config);
});
git-config is another npm package that reads and parses git configuration files. Unlike parse-git-config, git-config focuses more on providing a simpler and more direct approach to accessing git config values without the additional features for handling includes or synchronous parsing.
The ini package is used to parse INI files, which is the format used by git config files. While not specifically designed for git, it can be used to parse any INI file, including git configs. It lacks the git-specific enhancements of parse-git-config, such as understanding git-specific properties or includes.
Parse
.git/config
into a JavaScript object. sync or async.
npm i parse-git-config --save
var git = require('parse-git-config');
// sync
var config = git.sync();
// or async
git(function (err, config) {
// do stuff with err/config
});
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', ... } }
Install dev dependencies:
npm i -d && npm test
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue
Jon Schlinkert
Copyright (c) 2015 Jon Schlinkert
Released under the MIT license
This file was generated by verb on February 24, 2015.
FAQs
Parse `.git/config` into a JavaScript object. sync or async.
The npm package parse-git-config receives a total of 943,524 weekly downloads. As such, parse-git-config popularity was classified as popular.
We found that parse-git-config demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.