Skip to content

Releases: dinoboff/git-spawned-promise

0.1.1

09 Feb 01:33

Choose a tag to compare

Bug Fix

  • add missing example to npm’s package 39cd223

0.1.0

09 Feb 01:04

Choose a tag to compare

Initial implementation.

API

  • gitSpawnedPromise: function({gitDir: ?string}): GitClient

    Bound a GitClient to a local repository.

  • GitClient: function(cmd: string[], ?options: ClientOption): Promise<any,Error>

    Run the git command and settle once the git child process exit and the stdout/stderr pipe closes, or when either fail.

  • ClientOption: {ignore: ?boolean, sep: ?string, map: mapper[]}

    • ignore: ignore stdout when set to true (false by default).
    • sep: separator to split the stream (default to \n if a mapper is provided).
    • map: when splitting a stream, apply each element and replace the returned value. If the value is a promise it will resolve it.

    if sep or map are set, the gitCLient Promise will resolve to an Array.

  • Mapper: function(item: any): any

    A handler for a stream.Transformer for stdout. Unlike regular handler async values are passed via a Promise instead of a callback function, and returning null (or Promise<null>) does not close the stream; the Transformer would just skip the value.

    If the mapper throws or reject, the GitClient returned Promise will reject with that error.

  • GitClient.run: function(...cmd: string[]): Promise<void,GitError>

    gitClient.run(...cmd) is equivalent to gitClient(cmd, {capture: true}).

  • GitClient.get: function(...cmd: string[]): Promise<string,GitError>

    gitClient.get(...cmd) is equivalent to gitClient(cmd).

  • GitClient.array: function(...cmd: string[], ?options: ClientOption): Promise<any[],Error>

    gitClient.array(...cmd) is equivalent to gitClient(cmd, {sep: '\n', map: someMapperOrMappperArray}).