{"id":15626,"library":"git-log-parser","title":"Git Log Parser","description":"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.","status":"abandoned","version":"1.2.1","language":"javascript","source_language":"en","source_url":"https://github.com/bendrucker/git-log-parser","tags":["javascript"],"install":[{"cmd":"npm install git-log-parser","lang":"bash","label":"npm"},{"cmd":"yarn add git-log-parser","lang":"bash","label":"yarn"},{"cmd":"pnpm add git-log-parser","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Commonly used to collect the output stream of commit objects into a JavaScript array for easier processing.","package":"stream-to-array","optional":true}],"imports":[{"note":"The package exports a default object containing the `parse` method and `fields` property.","wrong":"import { parse } from 'git-log-parser';","symbol":"log","correct":"import log from 'git-log-parser';"},{"note":"CommonJS usage for older Node.js environments or projects.","symbol":"log","correct":"const log = require('git-log-parser');"},{"note":"`fields` is a property of the default exported `log` object, not a named export.","wrong":"import { fields } from 'git-log-parser';","symbol":"log.fields","correct":"import log from 'git-log-parser'; console.log(log.fields);"}],"quickstart":{"code":"import log from 'git-log-parser';\nimport toArray from 'stream-to-array';\n\nasync function getRecentCommits() {\n  try {\n    // Parse commits from the last 24 hours\n    const commitsStream = log.parse({\n      before: new Date(Date.now() - 24 * 60 * 60 * 1000) \n    });\n\n    // Collect all commits into an array\n    const commits = await toArray(commitsStream);\n\n    console.log(`Found ${commits.length} commits from the last 24 hours.`);\n    if (commits.length > 0) {\n      console.log('--- Latest Commit ---');\n      const latest = commits[0];\n      console.log(`Subject: ${latest.subject}`);\n      console.log(`Author: ${latest.author.name} <${latest.author.email}>`);\n      console.log(`Date: ${latest.author.date.toISOString()}`);\n      console.log(`Short SHA: ${latest.commit.short}`);\n    }\n  } catch (error) {\n    console.error(\"Failed to parse git log:\", error.message);\n    if (error.code === 'ENOENT' && error.syscall === 'spawn git') {\n      console.error('Make sure Git is installed and available in your system PATH.');\n    }\n  }\n}\n\ngetRecentCommits();","lang":"javascript","description":"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."},"warnings":[{"fix":"Consider using actively maintained alternatives or be prepared to fork and update the library for compatibility.","message":"The package has been abandoned since 2016. It may not be compatible with newer versions of Node.js, `git` CLI changes, or modern stream APIs without significant issues. Use with caution in new projects.","severity":"breaking","affected_versions":">=1.2.1"},{"fix":"Ensure `git` is installed on the system where the Node.js application runs and is included in the environment's PATH variable.","message":"This library relies on the `git` command-line tool being installed and accessible in the system's PATH. If `git` is not found, the parser will fail.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Install `stream-to-array` (`npm install stream-to-array`) and use `await toArray(log.parse(...))` to convert the stream to an array of commits.","message":"The `parse` method returns a Node.js Readable Stream. To get an array of commit objects, you need to pipe it to a consumer like `stream-to-array` or manually process the stream chunks.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"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`).","cause":"The `git` command is not found in the system's PATH.","error":"Error: spawn git ENOENT"},{"fix":"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.","cause":"Incorrect import statement or module not found.","error":"TypeError: Cannot read properties of undefined (reading 'parse') (or similar for 'fields')"}],"ecosystem":"npm"}