A pure-JavaScript implementation of git cat-file -p for Node.js.
import {openLocalRepo} from "git-cat-file";
const repo = openLocalRepo("repository/.git");
const commit = await repo.getCommit("HEAD");
const file = await commit.getFile("path/to/file.txt");
process.stdout.write(file.data);See types/git-cat-file.d.ts for the full type definitions and per-method documentation.
Usage:
git-cat-file-js [-C path] [-t | -p] <object>
git-ls-tree-js [-C path] [<options>] <tree-ish> [<path>...]
git-rev-parse-js [-C path] <args>...The CLI commands shipped with the package are also available as git subcommands when node_modules/.bin is on $PATH:
npm install git-cat-file
export PATH="node_modules/.bin:$PATH"
git cat-file-js [-t | -p] <object>
git ls-tree-js [<options>] <tree-ish> [<path>...]
git rev-parse-js <args>...