gift-wrapper

1.1.1 • Public • Published

gift-wrapper

A Q wrapper for the gift library to perform git operations in node.

Installation

It does not get any easier.

npm install gift-wrapper

API documentation

gift-wrapper API is (almost) exactly same as gift. Only differece is, instead of doing the folowing in gift

someObject.some_method( [arguments], callback );

we will be able to do the following in gift-wrapper

someObject.some_method( [arguments] )
.then( some_callback )
.fail( error_handler )

Here is the link to gift README file for API reference.

Special note about callbacks

There are two forms of callbacks in gift. They are-

  1. callback (error, result)
  2. callback (result)

However, callback function of form callback(error, result) is not present in gift-wrapper. Instead, the error parameter will be available in error handlers of Q promises (i.e. in fail() method) in appropriate situations. All other callback functions from gift remains same and results are avaialble in immediate then() after the call.

Synchronous execution

Although very rare, but there are few function in gift which executes in a synchronous manner and returns the result of execution directly, rather than via a callback function. This behavior remains the same in gift-wrapper to be consistent with gift.

Example

var gw = require("gift-wrapper");

var repo = gw("/path/to/local/repo");

repo.identity()
.then(function(id){
  console.log(id); // asynchronously getting author information from the repository
  return repo.status();
})
.then(function(status){
  console.log(status); // asynchronously getting status of the repository
})
.fail(console.error); // sending errors to print in stderr, if there is any error

var tree = repo.tree();
console.log(tree); // synchronously getting the tree from the repository

Readme

Keywords

Package Sidebar

Install

npm i gift-wrapper

Weekly Downloads

5

Version

1.1.1

License

MIT

Last publish

Collaborators

  • zpbappi