GitHub Command Helper For NodeJS

Hierarchy

  • git

Constructors

  • Parameters

    • gitdir: string
    • branch: string = 'master'

    Returns git

Properties

branch: string
cwd: string
email: string
exist: boolean
ext: index-exports = extension
getGithubBranches: ((opt?) => Promise<void | {
    active: boolean;
    branch: string;
}[]>) = GithubInfo.getGithubBranches

Type declaration

    • (opt?): Promise<void | {
          active: boolean;
          branch: string;
      }[]>
    • get current branch informations

      Parameters

      Returns Promise<void | {
          active: boolean;
          branch: string;
      }[]>

getGithubCurrentBranch: ((opt?) => Promise<string | void>) = GithubInfo.getGithubCurrentBranch

Type declaration

    • (opt?): Promise<string | void>
    • get current branch

      Parameters

      Returns Promise<string | void>

getGithubRemote: ((name?, opt?) => Promise<string | void>) = GithubInfo.getGithubRemote

Type declaration

getGithubRootDir: ((opt?) => Promise<string>) = GithubInfo.getGithubRootDir

Type declaration

helper: typeof default = helper
infos: {
    getGithubBranches: ((opt?) => Promise<void | {
        active: boolean;
        branch: string;
    }[]>);
    getGithubCurrentBranch: ((opt?) => Promise<string | void>);
    getGithubRemote: ((name?, opt?) => Promise<string | void>);
    getGithubRepoUrl: ((path, opt?) => Promise<{
        rawURL: string;
        remoteURL: string;
    }>);
    getGithubRootDir: ((opt?) => Promise<string>);
    getIgnores: ((param0) => Promise<string[]>);
} = GithubInfo

exports infos

Type declaration

  • getGithubBranches: ((opt?) => Promise<void | {
        active: boolean;
        branch: string;
    }[]>)
      • (opt?): Promise<void | {
            active: boolean;
            branch: string;
        }[]>
      • get current branch informations

        Parameters

        Returns Promise<void | {
            active: boolean;
            branch: string;
        }[]>

  • getGithubCurrentBranch: ((opt?) => Promise<string | void>)
      • (opt?): Promise<string | void>
      • get current branch

        Parameters

        Returns Promise<string | void>

  • getGithubRemote: ((name?, opt?) => Promise<string | void>)
  • getGithubRepoUrl: ((path, opt?) => Promise<{
        rawURL: string;
        remoteURL: string;
    }>)
      • (path, opt?): Promise<{
            rawURL: string;
            remoteURL: string;
        }>
      • Get github url for single file or folder

        Parameters

        • path: string

          path subfolder or file

        • opt: infoOptions = ...

        Returns Promise<{
            rawURL: string;
            remoteURL: string;
        }>

        safe url

  • getGithubRootDir: ((opt?) => Promise<string>)
  • getIgnores: ((param0) => Promise<string[]>)
      • (param0): Promise<string[]>
      • get all ignored files by .gitignore

        Parameters

        • param0: Object

        Returns Promise<string[]>

remote: string
submodule: submodule
user: string
ext: index-exports = extension
helper: typeof default = helper

Methods

  • git add

    Parameters

    • path: string

      specific path or argument -A

    • optionSpawn: SpawnOptions = ...

    Returns Bluebird<string>

  • add and commit file

    Parameters

    • path: string
    • msg: string
    • mode: string = 'm'

      am/m

    Returns Bluebird<unknown>

  • git config --global --add safe.directory PATH_FOLDER

    Returns Promise<string | void>

  • check if can be pushed

    Returns Promise<boolean>

  • git checkout

    Parameters

    Returns Promise<string>

  • git commit

    Parameters

    • msg: string

      commit messages

    • mode: string = 'm'

      am, -m, etc

    • optionSpawn: SpawnOptions = ...

    Returns Bluebird<string>

  • bulk add and commit

    Parameters

    • options: {
          msg?: string;
          path: string;
          [key: string]: any;
      }[]

      array of path and msg commit message

    Returns Bluebird<Error[]>

  • git fetch

    Parameters

    • Optional arg: string[]

      argument git-fetch, ex ['--all']

    • optionSpawn: SpawnOptions = ...

    Returns Bluebird<string>

  • get repository and raw file url

    Parameters

    • file: string

      relative to git root without leading /

    Returns Promise<{
        rawURL: string;
        remoteURL: string;
    }>

  • get current branch informations

    Returns Promise<{
        active: boolean;
        branch: string;
    }[]>

  • get remote information. default origin

    Parameters

    • args: string

    Returns Promise<string>

    remote url

  • get remote origin information

    Parameters

    • Optional args: string[]

    Returns Promise<{
        fetch: {
            origin: string;
            url: string;
        };
        push: {
            origin: string;
            url: string;
        };
    }>

    object remote

  • check has any file changed

    Returns Promise<boolean>

  • Returns Promise<{
        branch: {
            active: boolean;
            branch: string;
        }[];
        remote: {
            fetch: {
                origin: string;
                url: string;
            };
            push: {
                origin: string;
                url: string;
            };
        };
        root: string;
        status: StatusResult[];
    }>

  • git init

    Parameters

    Returns Promise<string | void>

  • Check if git folder exists

    Returns Bluebird<boolean>

  • is file ignored by .gitignore?

    Parameters

    Returns Promise<boolean | Return>

  • check file is untracked

    Parameters

    • file: string

      relative to git root without leading /

    Returns Promise<boolean>

  • Check if current repository is up to date with origin/remote

    Returns Bluebird<boolean>

  • get latest commit hash

    Parameters

    Returns Promise<string>

  • git pull

    Parameters

    • Optional arg: string[]

      example: ['--recurse-submodule']

    • optionSpawn: SpawnOptions = ...

    Returns Promise<string>

  • git push

    Parameters

    Returns any

  • Reset to latest commit of remote branch

    Parameters

    • branch: string = ...

    Returns Bluebird<string>

  • setup merge on pull strategy

    Returns Promise<{
        err: string;
        output: string;
        stderr: string;
        stdout: string;
    }>

  • setup end of line LF

    Link

    https://stackoverflow.com/a/13154031

    Returns Promise<{
        err: string;
        output: string;
        stderr: string;
        stdout: string;
    }>

  • set branch (git checkout branchName)

    Parameters

    • branchName: string
    • force: boolean = false
    • Optional spawnOpt: SpawnOptions

    Returns Promise<string | void>

  • Parameters

    • v: string

    Returns void

  • Parameters

    • v: string

    Returns Bluebird<string>

  • set remote url

    Example

    // default
    git add remote origin https://
    // custom name
    git add remote customName https://

    Parameters

    • remoteURL: string | URL

      repository url

    • Optional name: string

      custom object name

    • spawnOpt: SpawnOptions = {}

    Returns Promise<any>

  • Parameters

    • v: string

    Returns Bluebird<string>

  • call spawn async

    Parameters

    Returns Bluebird<string>

  • Spawn option default stdio pipe

    Type Parameters

    • T

    Parameters

    Returns Record<string, any> & CommonSpawnOptions & T