UNPKG

node-git-2-json

Version:

Simple tool to get a JSON from your git log. Inspired by @fabien0102/git2json

44 lines 2.29 kB
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; import { cleaner } from './cleaner.js'; import { formatter } from './formatter.js'; import { gitLog, handleOutput } from './git.js'; import { parser } from './parser.js'; export { gitLog, handleOutput, getFormat } from './git.js'; export { parser, parseNumbers, parseRefs, splitCommit, splitStat, parseParents, parseTimestamp } from './parser.js'; export { cleaner, removeKeys, sanitizeStrings } from './cleaner.js'; export { gitFormatMapping, lightSanitizeRules, heavySanitizeRules, sanitizeKeys, loggingEnabled, loggingPrefix, setLoggingEnabled, setLoggingPrefix } from './constants.js'; export { ProcessingError } from './error.js'; export { formatter, formatStats } from './formatter.js'; export function generateJson(repo, count, output, clean) { return __awaiter(this, void 0, void 0, function* () { count = count == undefined ? -1 : count; output = output == undefined ? 'JSON' : output; clean = clean == undefined ? {} : clean; const data = yield gitLog(repo, count); const indData = yield handleOutput(data[0], data[1]); const parseData = yield parser(indData); const formattedData = yield formatter(parseData); let cleanedData; if (Object.keys(clean).length != 0) { cleanedData = yield cleaner(formattedData, clean); } else { cleanedData = formattedData; } if (output == 'JSON') { return JSON.stringify(cleanedData); } else if (output == 'Object') { return cleanedData; } }); } //# sourceMappingURL=index.js.map