npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

git-log-parser

v1.2.1

Published

git-log-parser

Downloads

5,036,916

Readme

git-log-parser Build Status

Run git log and return a stream of commit objects.

Setup

$ npm install git-log-parser

API

log.parse(config, options) -> Stream(commits)

Accepts a config object mapping to the options accepted by git log. config will be automatically converted to command line options and flags by argv-formatter. Returns a stream of commit objects.

options is passed directly to child_process.spawn.

A commit is structured as follows:

{
  commit: {
    'long': '4bba6092ecb2571301ca0daa2c55336ea2c74ea2',
    'short': '4bba609'
  },
  tree: {
    'long': 'b4ef3379e639f8c0034831deae8f6ce63dd41566',
    'short': 'b4ef337'
  },
  author: {
    'name': 'Ben Drucker',
    'email': '[email protected]',
    'date': new Date('2014-11-20T14:39:01.000Z')
  },
  committer: {
    'name': 'Ben Drucker',
    'email': '[email protected]',
    'date': new Date('2014-11-20T14:39:01.000Z')
  },
  subject: 'Initial commit',
  body: 'The commit body'
}

author.date and commiter.date are Date objects while all other values are strings.

If you just want an array of commits, use stream-to-array to wrap the returned stream.

log.fields -> Object

Commit objects contain the most frequently used commit information. However, the field mappings used to format and then parse log output can be amended before calling the parser. Consult the full range of formatting placeholders and add the placeholder to the object tree if you wish to add extra fields.

Example

Get all commits from earlier than an hour ago and stream them to stdout as pretty-printed JSON

var log      = require('git-log-parser');
var through2 = require('through2');

log.parse({
  before: new Date(Date.now() - 60 * 60 * 1000)
})
.pipe(through2.obj(function (chunk, enc, callback) {
  callback(null, JSON.stringify(chunk, undefined, 2));
}))
.pipe(process.stdout);

Note that before is stringified and passed directly as an argument to git log. No special handling is required for any standard git log option. You can filter by committer, time, or any other field supported by git log.