An open API service indexing awesome lists of open source software.

https://github.com/zpbappi/gift-wrapper

A `Q` wrapper for the `gift` library to perform git operations in node
https://github.com/zpbappi/gift-wrapper

Last synced: 6 months ago
JSON representation

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

Awesome Lists containing this project

README

          

# gift-wrapper
A [Q](https://github.com/kriskowal/q) wrapper for the [gift](https://github.com/notatestuser/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`
```js
someObject.some_method( [arguments], callback );
```

we will be able to do the following in `gift-wrapper`
```js
someObject.some_method( [arguments] )
.then( some_callback )
.fail( error_handler )
```

Here is the link to [gift README file](https://github.com/notatestuser/gift/blob/master/README.md) 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
```js
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
```