git-log-parser is a Node.js library designed to execute the `git log` command and stream its output as structured JavaScript objects. Released in 2015 with its latest stable version 1.2.1, it provides a programmatic interface to extract commit metadata such as commit hashes, author and committer details (name, email, date), subject, and body. It handles the conversion of configuration objects into command-line arguments for `git log` using `argv-formatter` and spawns a `child_process` to execute the `git` command. While functional, the package has seen no updates since its last release, indicating an abandoned status. Developers should be aware of its reliance on an external `git` installation and the need for stream processing libraries (like `through2` or `stream-to-array`) to consume its output as an array. Its primary differentiator is simplifying the interaction with `git log` by abstracting command-line argument formatting and providing parsed object streams.
npm install git-log-parserVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to use git-log-parser to retrieve commits from the last 24 hours, collect them into an array, and print details of the latest commit. It also includes basic error handling for common issues like 'git' not found.
Consider using actively maintained alternatives or be prepared to fork and update the library for compatibility.
Ensure `git` is installed on the system where the Node.js application runs and is included in the environment's PATH variable.
Install `stream-to-array` (`npm install stream-to-array`) and use `await toArray(log.parse(...))` to convert the stream to an array of commits.
Install Git on your system and ensure its executable path is added to your environment variables. For Windows, reinstall Git and select the option to add Git to PATH. For Linux/macOS, ensure Git is installed (e.g., `sudo apt-get install git` or `brew install git`).
If using ESM, ensure you are using `import log from 'git-log-parser';` (default import). If using CommonJS, use `const log = require('git-log-parser');`. Verify the package is correctly installed.