@dword-design/parse-git-config

中文文档
0.0.1发布于 2025/05/31MITCommonJS近 30 天下载 6025

解析 .git/config 输入 JavaScript 对象。 同步或同步 .

中文使用文档
文档目录16 节
  1. 安装
  2. 使用量
  3. 选项
  4. 数据
  5. 路径
  6. 示例配置对象
  7. API 密码
  8. 剖析
  9. .同步
  10. 扩展键
  11. .扩展关键字示例
  12. 关于
  13. 相关项目
  14. 贡献者
  15. 作者
  16. 许可证

剖析- git- 配置 NPM version NPM monthly downloads NPM total downloads Linux Build Status

解析 .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

您可能也对这些项目感兴趣:

贡献者

| 提交 | 贡献者 |
| -- -- -- -- -- -- --
| 66 | 扬施林克特 |
页:1 鸽子 |
| 1 | 大卫 |
| 1 | 莱克萨斯 |
| 1 | 萨姆3d |
| 1 | 苏拉绍尔语name |

作者

乔恩·斯林克特

许可证

版权: 2018, 乔恩·斯林克特。 。 。 . 释放 MIT 许可证。 。 。 .


此文件由 动词基因读取器,v0.8.0,于2018年11月20日查阅.

版本与发布记录

@dword-design/parse-git-config 共发布 1 个版本,首次发布于 2025/05/31;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.0.1latest2025/05/311.5 年前

关于 @dword-design/parse-git-config 的常见问题

@dword-design/parse-git-config 是什么?

解析 .git/config 输入 JavaScript 对象。 同步或同步 .

如何安装 @dword-design/parse-git-config?

在项目目录运行 npm install @dword-design/parse-git-config,或使用 pnpm add / yarn add / bun add。

@dword-design/parse-git-config 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/dword-design__parse-git-config 是否存在。

@dword-design/parse-git-config 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@dword-design/parse-git-config 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=8。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@dword-design/parse-git-config 可以商用吗?

@dword-design/parse-git-config 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@dword-design/parse-git-config 的下载量有多少?

根据 npm 官方下载统计,@dword-design/parse-git-config 在 2026/10/13 – 2026/11/11 这 30 天内被下载 6,025 次,日均约 201 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@dword-design/parse-git-config 还在维护吗?

最新版本 0.0.1 发布于 2025/05/31(1.5 年前);至今共发布 1 个版本,其中过去 12 个月发布了 0 个;首次发布于 2025/05/31。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。