const parse = require('{%= name %}');
// sync
console.log(parse.sync());
// using async/await
(async () => console.log(await parse()))();
The starting directory to search from.
Type: string
Default: process.cwd()
(current working directory)
Either the absolute path to .git config
, or the path relative to the current working directory.
Type: string
Default: .git/config
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', ... } }
{%= apidocs('index.js') %}
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
}
}
}