1.4.0 • Published 6 years ago

@fabien0102/git2json v1.4.0

Weekly downloads
69
License
MIT
Repository
github
Last release
6 years ago

git2json

Build Status Code Climate Issue Count Test Coverage npm version

Simple tool to get a JSON from your git log.

CLI usage

  1. Install package globally -> npm i -g @fabien0102/git2json or yarn global add @fabien0102/git2json
  2. Navigate to your local git repository folder
  3. Do git2json > export.json
  4. Voilà!

Lib usage

  1. Add dependency -> npm i -s @fabien0102/git2json or yarn add @fabien0102/git2json
  2. Use it!
const git2json = require('@fabien0102/git2json');

git2json
  .run()
  .then(myGitLogJSON => console.log(myGitLogJSON));

Advanced usage

If needed, you have access to parsers and defaultFields for easy overriding.

Example:

const git2json = require('@fabien0102/git2json');
const exportedFields = {
  author: git2json.defaultFields['author.name'],
  commit: git2json.defaultFields.commit,
  shortTree: { value: '%T', parser: a => a.slice(0, 5)}
};

git2json
  .run({fields: exportedFields})
  .then(json => console.log(json));

You can also specify a path for the git repository. Just like the above options, doing so is optional with sane defaults. Here is an example use case combining multiple git commit logs.

const git2json = require('@fabien0102/git2json');
const paths = ['~/etc', '~/src/hack/git2json'];

const logPs = paths.map(path => git2json.run({ path }));

Promise.all(logPs).then(json => [].concat(...json)).then(console.log);
1.4.0

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago