A Q wrapper for the gift library to perform git operations in node.
It does not get any easier.
npm install gift-wrapper
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.
There are two forms of callbacks in gift
. They are-
callback (error, result)
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.
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
.
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