剖析- git- 配置

解析
.git/config输入 JavaScript 对象。 同步或同步 .
请考虑跟随这个项目的作者, 乔恩·斯林克特,并考虑主演该项目以显示你的:心:和支持.
安装
安装方式 无数字 :
$ npm install --save parse-git-config
使用量
const parse = require('parse-git-config');
// sync
console.log(parse.sync());
// using async/await
(async () => console.log(await parse()))();
选项
数据
要搜索的起始目录 .
类型数字 : string
默认数字 : process.cwd() (当前工作目录)
路径
要么绝对路径去.git config,或相对于当前工作目录的路径.
类型数字 : string
默认数字 : .git/config
示例配置对象
已解析的配置对象将看起来像:
{ 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 密码
剖析
同步解析 a .git/config 文档。 如果只通过回调 .git/config 文件相对 process.cwd() 已使用.
参数
options{Object} {String {功能}\fn方正黑体简体\fs18\b1\bord1\shad1\3cH2F2F2F}选项cwd或者说path,或调用函数.callback{职能}: 如果第一个参数是选项或cwd,则召回函数.returns{对象}
示例
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' }));
})();
.同步
同步解析 a .git/config 文档。 如果没有通过辩论 .git/config 文件相对 process.cwd() 已使用.
参数
options{对象}选项cwd或者说path,或使用cwd.returns{对象}
示例
console.log(parse.sync());
console.log(parse.sync({ cwd: 'foo' }));
console.log(parse.sync({ cwd: 'foo', path: 'some/.git/config' }));
扩展键
返回一个对象,其属性只包含已转换成对象的ini-tyle密钥.
参数
config{对象}:被解析出 git 配置对象.returns{对象}
示例
const config = parse.sync({ path: '/path/to/.gitconfig' });
const obj = parse.expandKeys(config);
.扩展关键字示例
将 Ini 风格密钥转换为对象 :
实例1
const parse = require('parse-git-config');
const config = {
'foo "bar"': { doStuff: true },
'foo "baz"': { doStuff: true }
};
console.log(parse.expandKeys(config));
成果:
{
foo: {
bar: { doStuff: true },
baz: { doStuff: true }
}
}
实例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));
成果:
{
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
}
}
}
关于
捐款
拉出请求和星星总是受欢迎的. 对于错误和特性请求, 请创建一个问题。 。 。 .
运行测试
运行和审查单元测试是熟悉图书馆及其API的好办法。 您可以使用以下命令安装依赖性并运行测试:
$ npm install && npm test
大楼文件
(此工程的 readme.md 由 动词请不要直接编辑读取器。 读取器的任何改动必须在 动词 md 读取我的模板。 )
要生成读取, 请运行以下命令 :
$ npm install -g verbose/verb#dev verb-generate-readme && verb
相关项目
您可能也对这些项目感兴趣:
- git 用户名:根据 更多 | 主页
- git 用户名: 从 git/ GitHub 远程源代码 URL 中获取用户名( 或“ 所有人” 名称 ) 。 主页
- 剖析作者: 将作者、 贡献者、 维护者或其他“ 人物” 字符串分析成有名称、 电子邮件的对象.. 更多 | 主页
- 剖析作者: 将字符串分析为对象数组
name, (中文(简体) ),email财务报告和审定财务报表url属性跟随.. 更多 | 主页 - 剖析- github-url: 将一个 github URL 分析为对象 。\\\\ x 主页
- 解析吉他: 将一个.gitignore或.npmignore文件分解为一系列图案. XQ 主页
贡献者
| 提交 | 贡献者 |
| -- -- -- -- -- -- --
| 66 | 扬施林克特 |
页:1 鸽子 |
| 1 | 大卫 |
| 1 | 莱克萨斯 |
| 1 | 萨姆3d |
| 1 | 苏拉绍尔语name |
作者
乔恩·斯林克特
许可证
版权: 2018, 乔恩·斯林克特。 。 。 . 释放 MIT 许可证。 。 。 .
此文件由 动词基因读取器,v0.8.0,于2018年11月20日查阅.