@sumor/git

1.0.4 • Public • Published

git

A Sumor Cloud Tool.
More Documentation

A git version library, easily packaging version and generate specific package with env.

NPM Version NPM Downloads GitHub CI GitHub Test GitHub Coverage GitHub Audit

Installation

npm i @sumor/git --save

Prerequisites

Node.JS version

Require Node.JS version 18.x or above

require Node.JS ES module

As this package is written in ES module, please change the following code in your package.json file:

{
  "type": "module"
}

Usage

import git from '@sumor/git'
const config = {
  // git url and credentials
  url: '<git url>', // mandatory
  token: '<git token>', // mandatory, if username and password are not provided
  username: '<git username>', // mandatory, if token is not provided
  password: '<git password>' // mandatory, if token is not provided
}
const repository = await git(config, path)

const commit1 = await repository.currentCommit() // get current commit
const commitTime1 = await repository.currentCommitTime() // get current commit time, in milliseconds

await repository.checkout('<target commit>') // can be a branch or a tag or a commit
const commit2 = await repository.currentCommit() // get current commit

// if you installed Github Desktop, you can use below command to open it in Github Desktop
await repository.github()

Create new local repository

When you pass null as config, it will create a new repository in local path.

await git(null, path1)

// usage for local repository
const repository = await git({ url: path1 }, path2)

/@sumor/git/

    Package Sidebar

    Install

    npm i @sumor/git

    Weekly Downloads

    1,120

    Version

    1.0.4

    License

    MIT

    Unpacked Size

    9.14 kB

    Total Files

    10

    Last publish

    Collaborators

    • ohnow