🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

gitconfiglocal

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
n

gitconfiglocal

parse the .git/config file into a useful data structure

2.1.0
latest
100

Supply Chain Security

100

Vulnerability

75

Quality

76

Maintenance

100

License

Version published
Weekly downloads
3.4M
-0.67%
Maintainers
1
Weekly downloads
 
Created
Issues
4

What is gitconfiglocal?

The gitconfiglocal npm package allows you to read and manipulate local Git configuration files. It provides a simple API to access and modify the .git/config file in a Git repository.

What are gitconfiglocal's main functionalities?

Read Local Git Config

This feature allows you to read the local Git configuration of a repository. The code sample demonstrates how to use the gitconfiglocal package to read the .git/config file of a specified repository.

const gitconfiglocal = require('gitconfiglocal');
const path = require('path');

const repoPath = path.resolve('/path/to/repo');
gitconfiglocal(repoPath, (err, config) => {
  if (err) throw err;
  console.log(config);
});

Modify Local Git Config

This feature allows you to modify the local Git configuration of a repository. The code sample demonstrates how to read the .git/config file, modify the user name and email, and then write the changes back to the file.

const gitconfiglocal = require('gitconfiglocal');
const fs = require('fs');
const ini = require('ini');
const path = require('path');

const repoPath = path.resolve('/path/to/repo');
gitconfiglocal(repoPath, (err, config) => {
  if (err) throw err;
  config.user.name = 'New User';
  config.user.email = 'newuser@example.com';
  fs.writeFileSync(path.join(repoPath, '.git', 'config'), ini.stringify(config));
});

Other packages similar to gitconfiglocal

Keywords

FAQs

Package last updated on 15 Feb 2019

Did you know?

Socket

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.

Install

Related posts