index.js
function (command, options) {
        var exec = require('child_process').exec;
        var defer = Q.defer();

        //Prepare the options object to be valid
        options = prepareOptions(options);

        //Activate-Deactivate command logging execution
        printCommandExecution(command, options);

        exec('git ' + prepareCommand(command), options, function (err, stdout, stderr) {
            //Activate-deactivate err and out logging
            printCommandResponse({err:err, stdout:stdout, stderr:stderr});

            if (err) {
                defer.reject({err: err, stderr: stderr});
            } else {
                defer.resolve({res:stdout, out:stderr});
            }
        });

        return defer.promise;
    }
function (command, options) {
        var exec = require('child_process').exec;
        var defer = Q.defer();

        //Prepare the options object to be valid
        options = prepareOptions(options);

        //Activate-Deactivate command logging execution
        printCommandExecution(command, options);

        exec('git ' + prepareCommand(command), options, function (err, stdout, stderr) {
            //Activate-deactivate err and out logging
            printCommandResponse({err:err, stdout:stdout, stderr:stderr});

            if (err) {
                defer.reject({err: err, stderr: stderr});
            } else {
                defer.resolve({res:stdout, out:stderr});
            }
        });

        return defer.promise;
    }
function ( command , options ) { var exec = require ( 'child_process' ) . exec ; var defer = Q . defer ( ) ; //Prepare the options object to be valid options = prepareOptions ( options ) ; //Activate-Deactivate command logging execution printCommandExecution ( command , options ) ; exec ( 'git ' + prepareCommand ( command ) , options , function ( err , stdout , stderr ) { //Activate-deactivate err and out logging printCommandResponse ( { err : err , stdout : stdout , stderr : stderr } ) ; if ( err ) { defer . reject ( { err : err , stderr : stderr } ) ; } else { defer . resolve ( { res : stdout , out : stderr } ) ; } } ) ; return defer . promise ; }
Main function to use the command line tools to execute git commands
@param command   Command to execute. Do not include 'git ' prefix
@param options   Options available in exec command https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback
@returns {promise|*|Q.promise}
Main function to use the command line tools to execute git commands