@abysser/jit
TypeScript icon, indicating that this package has built-in type declarations

1.3.11 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i @abysser/jit

Weekly Downloads

0

Version

1.3.11

License

MIT

Unpacked Size

30.3 kB

Total Files

11

Last publish

Collaborators

  • morilence