GitHub Command Helper For NodeJS

Hierarchy

  • git

Constructors

  • Parameters

    • dir: string

    Returns git

Properties

branch: string
cwd: string
email: string
exist: any
getGithubBranches: ((opt?: SpawnOptions) => Promise<void | {
    active: boolean;
    branch: string;
}[]>)

Type declaration

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

      Returns

      Parameters

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

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

Type declaration

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

      Returns

      Parameters

      Returns Promise<string | void>

getGithubRemote: ((name?: null | string, opt?: SpawnOptions) => Promise<string | void>)

Type declaration

getGithubRepoUrl: ((path: string, opt?: SpawnOptions) => Promise<{
    rawURL: string;
    remoteURL: string;
}>)

Type declaration

    • (path: string, opt?: SpawnOptions): Promise<{
          rawURL: string;
          remoteURL: string;
      }>
    • Get github url for single file or folder

      Parameters

      • path: string

        path subfolder or file

      • Optional opt: SpawnOptions

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

getGithubRootDir: ((opt?: SpawnOptions) => Promise<string | void>)

Type declaration

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

Type declaration

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

        Returns

        Parameters

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

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

        Returns

        Parameters

        Returns Promise<string | void>

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

        Parameters

        • path: string

          path subfolder or file

        • Optional opt: SpawnOptions

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

  • getGithubRootDir: ((opt?: SpawnOptions) => Promise<string | void>)
latestCommit: ((path?: string, options?: Partial<GetLatestCommitHashOptions>) => Promise<string>)

Type declaration

remote: string
spawnOpt: any

Spawn option default stdio pipe

Param

Returns

submodule: submodule
user: string
helper: typeof default
noop: ((..._: any[]) => void)

Type declaration

    • (..._: any[]): void
    • Parameters

      • Rest ..._: any[]

      Returns void

shell: ((cmd: string, args: string[], opt?: ShellOptions) => Promise<string | void | Buffer>)

Type declaration

    • (cmd: string, args: string[], opt?: ShellOptions): Promise<string | void | Buffer>
    • asynchronous spawner

      Returns

      Parameters

      Returns Promise<string | void | Buffer>

Methods

  • git add

    Returns

    Parameters

    • path: string

      specific path or argument -A

    • Optional optionSpawn: SpawnOptions

    Returns Bluebird<string>

  • add and commit file

    Returns

    Parameters

    • path: string
    • msg: string
    • Optional mode: string

      am/m

    Returns Bluebird<unknown>

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

    Returns Promise<string | void>

  • check if can be pushed

    Parameters

    • Optional originName: string

      origin name

    • Optional branchName: string

    Returns Promise<boolean>

  • Returns boolean

  • git checkout

    Returns

    Parameters

    Returns Promise<string>

  • git commit

    Returns

    Parameters

    • msg: string

      commit messages

    • Optional mode: string

      am, -m, etc

    • Optional optionSpawn: SpawnOptions

    Returns Bluebird<string>

  • bulk add and commit

    Returns

    Parameters

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

      array of path and msg commit message

    Returns Bluebird<Error[]>

  • git fetch

    Returns

    Parameters

    • Optional arg: string[]

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

    • Optional optionSpawn: SpawnOptions

    Returns Bluebird<string>

  • get current branch informations

    Returns

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

  • get remote information

    Returns

    Parameters

    • Optional args: string[]

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

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

  • git init

    Returns

    Parameters

    Returns Promise<string | void>

  • Check if git folder exists

    Returns

    Returns Bluebird<boolean>

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

    Returns

    Returns Bluebird<boolean>

  • git pull

    Returns

    Parameters

    • Optional arg: string[]

      example: ['--recurse-submodule']

    • Optional optionSpawn: SpawnOptions

    Returns Promise<string>

  • git push

    Returns

    Parameters

    Returns any

  • Reset to latest commit of remote branch

    Parameters

    • Optional branch: string

    Returns Bluebird<string>

  • setup merge on pull strategy

    Returns

    Returns Bluebird<string>

  • set branch (git checkout branchName)

    Returns

    Parameters

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

    Returns Promise<string | void>

  • Parameters

    • v: string

    Returns void

  • Parameters

    • v: string

    Returns Bluebird<string>

  • set remote url

    Returns

    Example

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

    Parameters

    • v: string | URL
    • Optional name: string

      custom object name

    • Optional spawnOpt: SpawnOptions

    Returns Promise<any>

  • Parameters

    • v: string

    Returns Bluebird<string>

  • call spawn async

    Returns

    Parameters

    Returns Bluebird<string>