@git-lazy/const

中文文档
2.0.3发布于 2026/08/30ISCTypeScriptESM + CJS零依赖近 30 天下载 4465

Constants for git subprocess execution, including buffer size limits to prevent ENOBUFS errors

原始使用文档
文档目录5 节
  1. Installation
  2. Usage
  3. API
  4. GitExecMaxBuffer
  5. License

@git-lazy/const

Constants for git subprocess execution, including buffer size limits to prevent ENOBUFS errors

Installation

npm install @git-lazy/const
# or
pnpm add @git-lazy/const
# or
yarn add @git-lazy/const

Usage

import { GitExecMaxBuffer } from '@git-lazy/const';
import { execSync } from 'child_process';

// 執行可能產生大量輸出的 git 命令
// Execute git commands that may produce large output
const output = execSync('git log --all --oneline', {
  maxBuffer: GitExecMaxBuffer,
});

API

GitExecMaxBuffer

Git 執行緩衝區上限常數 / Git execution buffer size limit constant

防止 git 子程序執行時因輸出過大而觸發 ENOBUFS(緩衝區溢出)錯誤。當 git 命令產生大量輸出(如大型倉庫的 git log 或 git diff)時,預設緩衝區大小不足會導致程序異常終止。

Prevents ENOBUFS (buffer overflow) errors when executing git subprocesses due to excessive output. When git commands produce large amounts of output (such as git log or git diff for large repositories), the default buffer size may be insufficient, causing the process to terminate abnormally.

Value: 104857600 (100 MB / 1024 * 1024 * 100)

Example:

import { GitExecMaxBuffer } from '@git-lazy/const';
import { execSync } from 'child_process';

// 使用 execSync 執行 git 命令
// Execute git command with execSync
const output = execSync('git log --all --oneline', {
  maxBuffer: GitExecMaxBuffer,
});
import { GitExecMaxBuffer } from '@git-lazy/const';
import { execa } from 'execa';

// 使用 execa 執行 git 命令
// Execute git command with execa
const { stdout } = await execa('git', ['diff', '--stat'], {
  maxBuffer: GitExecMaxBuffer,
});

License

ISC

版本与发布记录

@git-lazy/const 共发布 9 个版本,首次发布于 2022/02/16;过去 12 个月发布了 1 个版本。

版本发布日期距今
2.0.3latest2026/08/302 个月前
1.0.92024/03/102 年前
1.0.82022/10/294 年前
1.0.72022/10/014 年前
1.0.62022/10/014 年前
1.0.52022/08/284 年前

关于 @git-lazy/const 的常见问题

@git-lazy/const 是什么?

Constants for git subprocess execution, including buffer size limits to prevent ENOBUFS errors

如何安装 @git-lazy/const?

在项目目录运行 npm install @git-lazy/const,或使用 pnpm add / yarn add / bun add。

@git-lazy/const 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@git-lazy/const 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@git-lazy/const 可以商用吗?

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

@git-lazy/const 的下载量有多少?

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

@git-lazy/const 还在维护吗?

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