@fabien0102/git2json
v1.4.0
Published
Simple tool to get a JSON from your git log.
Downloads
70
Readme
git2json
Simple tool to get a JSON from your git log.
CLI usage
- Install package globally ->
npm i -g @fabien0102/git2json
oryarn global add @fabien0102/git2json
- Navigate to your local git repository folder
- Do
git2json > export.json
- Voilà!
Lib usage
- Add dependency ->
npm i -s @fabien0102/git2json
oryarn add @fabien0102/git2json
- 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);