gitlog-emitter

1.0.0 • Public • Published

gitlog-emitter

Current Version Build Status via Travis CI Dependencies

belly-button-style

Emit individual commits in a git log as events. This module exposes a single constructor that inherits from EventEmitter. The emitter executes git --no-pager log in the directory passed to the constructor. Each commit in the log is then emitted as a 'commit' event. Once the entire log has been processed, a 'finish' event is emitted.

Example

const GitLogEmitter = require('gitlog-emitter');
const ee = new GitLogEmitter({ repo: 'path_local_git_repository' });
 
ee.on('commit', (commit) => {
  // Emitted for each commit in the git log.
  // The commit object has a hash, author, date, and message.
  console.log(commit);
});
 
ee.on('finish', () => {
  // Emitted after the last commit event.
});

API

This module exports a single constructor function:

  • GitLogEmitter(options) (function) - Inherits from EventEmitter. options is a configuration object with the following schema:
    • repo (string) - The path to a local git repository. git --no-pager log must be able to run in this directory.

Once constructed, the emitter emits the following events:

  • 'commit' - Includes details about individual commits. Event handlers are passed an object with the following schema:
    • hash (string) - The commit hash.
    • author (string) - The Author metadata for the commit.
    • date (string) - The Date metadata for the commit.
    • message (string) - Text describing the commit.
  • 'finish' - Emitted after the final commit event. No additional parameters are passed to the event handler.

Package Sidebar

Install

npm i gitlog-emitter

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • cjihrig