@fabien0102/git2json

1.4.0 • Public • Published

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);

Dependencies (0)

    Dev Dependencies (3)

    Package Sidebar

    Install

    npm i @fabien0102/git2json

    Weekly Downloads

    396

    Version

    1.4.0

    License

    MIT

    Unpacked Size

    164 kB

    Total Files

    19

    Last publish

    Collaborators

    • fabien0102