UNPKG

@git-temporal/git-log-scraper

Version:

Scrapes commit data from the git cli for a file or directory in a repository and returns an array of Javascript objects representing commits with files and lines added and deleted.

31 lines (27 loc) 963 B
#!/usr/bin/env node "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const gitLogScraper_1 = require("./gitLogScraper"); const commons_1 = require("@git-temporal/commons"); const HELP = ` Dumps git log json for a file or directory. usage: npx @git-temporal/git-log-scraper <pathToGitDirOrFile> [skip] [maxCount] examples: # get log data for current directory in a git repo npx @git-temporal/git-log-scraper . # get log data for a file in a git repo npx @git-temporal/git-log-scraper src/someFile.js `; debugger; const [path, skip, maxCount] = process.argv.slice(2); if (!path || path === '--help') { console.log(HELP); process.exit(1); } const commitHistory = gitLogScraper_1.getCommitHistory(path, { skip: commons_1.safelyParseInt(skip), maxCount: commons_1.safelyParseInt(maxCount), }); console.warn(`parsed ${commitHistory.commits.length} commits`); console.log(JSON.stringify(commitHistory, null, 2));