@abysser/jit
v1.3.11
Published
A lightweight nodejs-client of Git.
Readme
Jit
A lightweight nodejs-client of Git.
Quick Start
Install:
npm install @abysser/jitImport:
const { jit } = require("@abysser/jit");Usage
Create or index a Repo object:
const repo = jit.repo(/* absolute path of a local repository */);Get basic infos of the repo:
console.log(repo.root);
console.log(repo.cwd);
console.log(repo.branch);
console.log(repo.head);Run the git command:
repo.do("log", ["--oneline"]);Pass parameters directly:
repo.do("log", ["--pretty=format:%an", "--", "src/index.ts"]);Pass parameters by replacing <xxx>:
repo.do("log", ["--pretty=format:<string>", "--", "<path>"], "%an", "src/index.ts");do(command: NullCommand | GitCommand, args: GitArg[] | GitCommandArg[] = [], ...params: string[]): Pick<GitReturns, "pid" | "stdout"> & { formatted?: ReturnType<Formatter> }
Switch the current working directory:
repo.cd("src/routes");cd(...paths: string[]): Repo
Called in a chain:
repo.cd("src").cd("../").do("add", ["--all"]);License
Copyright 2022 Abyssers
