gitlog-emitter
v1.0.0
Published
git log Commits Event Emitter
Downloads
5
Maintainers
Readme
gitlog-emitter
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 fromEventEmitter
.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) - TheAuthor
metadata for the commit.date
(string) - TheDate
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.