simple-git
Advanced tools
Comparing version 0.9.0 to 0.10.0
{ | ||
"name": "simple-git", | ||
"description": "Simple GIT interface for node.js", | ||
"version": "0.9.0", | ||
"version": "0.10.0", | ||
"author": "Steve King <steve@mydev.co>", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
@@ -70,2 +70,5 @@ # Simple Git | ||
`outputHandler(handlerFn)` attaches a handler that will be called with the name of the command being run and the | ||
`stdout` and `stderr` [readable streams](http://nodejs.org/api/stream.html#stream_class_stream_readable) created by | ||
the [child process](http://nodejs.org/api/child_process.html#child_process_class_childprocess) running that command. | ||
@@ -100,1 +103,10 @@ # Examples | ||
// piping to the console for long running tasks | ||
require('simple-git')() | ||
.outputHandler(function (command, stdout, stderr) { | ||
stdout.pipe(process.stdout); | ||
stderr.pipe(process.stderr); | ||
}) | ||
.checkout('https://github.com/user/repo.git'); | ||
@@ -22,2 +22,7 @@ (function() { | ||
/** | ||
* @type {Function} An optional handler to use when a child process is created | ||
*/ | ||
Git.prototype._outputHandler = null; | ||
/** | ||
@@ -36,2 +41,23 @@ * Sets the path to a custom git binary, should either be `git` when there is an installation of git available on | ||
/** | ||
* Sets a handler function to be called whenever a new child process is created, the handler function will be called | ||
* with the name of the command being run and the stdout & stderr streams used by the ChildProcess. | ||
* | ||
* @example | ||
* require('simple-git') | ||
* .outputHandler(function (command, stdout, stderr) { | ||
* stdout.pipe(process.stdout); | ||
* }) | ||
* .checkout('https://github.com/user/repo.git'); | ||
* | ||
* @see http://nodejs.org/api/child_process.html#child_process_class_childprocess | ||
* @see http://nodejs.org/api/stream.html#stream_class_stream_readable | ||
* @param {Function} outputHandler | ||
* @returns {Git} | ||
*/ | ||
Git.prototype.outputHandler = function(outputHandler) { | ||
this._outputHandler = outputHandler; | ||
return this; | ||
}; | ||
/** | ||
* Initialize a git repo | ||
@@ -457,2 +483,8 @@ * | ||
}.bind(this)); | ||
if (this._outputHandler) { | ||
this._outputHandler(command.split(' ')[0], | ||
this._childProcess.stdout, | ||
this._childProcess.stderr); | ||
} | ||
} | ||
@@ -459,0 +491,0 @@ }; |
20308
456
111