gitlog is a Node.js library designed to parse output from the `git log` command into structured JavaScript objects. Currently at version 5.1.0, it provides a comprehensive programmatic interface to execute `git log` with various options and efficiently process the results. The library supports a wide array of filtering and formatting options, mirroring the capabilities of the native Git CLI. It ships with full TypeScript support, offering type-safe interaction and an enhanced developer experience, particularly with its `GitlogOptions` type for configuration and type inference for the returned commit objects based on selected fields. Releases occur periodically with a mix of patch and minor versions, indicating active maintenance. Its primary differentiator is the direct execution of the `git` CLI, ensuring high fidelity with Git's robust features and providing detailed commit information including changed files, authors, dates, and custom log fields.
npm install gitlogVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates fetching the last 5 commits from a local Git repository, specifying custom fields and leveraging TypeScript for type safety, including handling potential errors.
Update `catch` blocks to check for `Error` instances, e.g., `try { /* ... */ } catch (error) { if (error instanceof Error) { console.error(error.message); } else { console.error(String(error)); } }`.Refactor CommonJS `require()` statements to ES Module `import` statements. Ensure your project is configured for ESM, typically by setting `"type": "module"` in `package.json` or using `.mjs` file extensions.
Upgrade `gitlog` to version 4.0.4 or higher immediately: `npm install gitlog@latest`.
Add `as const` to your `fields` array definition: `fields: ['hash', 'subject', 'authorName'] as const`.
Increase `maxBuffer` in `execOptions` to accommodate larger outputs: `execOptions: { maxBuffer: 1024 * 1024 * 5 }` (for 5MB, adjust value as needed based on your repository size).Increase the `maxBuffer` option in `execOptions`: `execOptions: { maxBuffer: 1024 * 1024 * 5 }` (for 5MB, adjust as necessary).Install Git on your operating system and ensure its executable is accessible from your shell's PATH. Restart your application or development environment after installation.
Append `as const` to your `fields` array definition to provide literal type inference: `fields: ['hash', 'subject', 'authorName'] as const`.
No dependency data recorded yet.