Skip to content

Abyssers/jit

Repository files navigation

Jit

A lightweight nodejs-client of Git.

Quick Start

Install:

npm install @abysser/jit

Import:

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

MIT

Copyright 2022 Abyssers

About

A lightweight nodejs-client of Git

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published