simple-git
Advanced tools
Comparing version 1.1.0 to 1.2.0
{ | ||
"name": "simple-git", | ||
"description": "Simple GIT interface for node.js", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"author": "Steve King <steve@mydev.co>", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
@@ -63,2 +63,4 @@ # Simple Git | ||
`.silent(isSilent)` sets whether the console should be used for logging errors (defaults to `true` when the `NODE_ENV` contains the string `prod`) | ||
`.rm([fileA, ...], handlerFn)` removes any number of files from source control | ||
@@ -65,0 +67,0 @@ |
@@ -5,6 +5,2 @@ (function () { | ||
var Buffer = require('buffer').Buffer; | ||
var log = 'info warn error'.split(' ').reduce(function (log, level) { | ||
log[level] = /prod/.test(process.env.NODE_ENV) ? function () {} : console[level].bind(console); | ||
return log; | ||
}, {}); | ||
@@ -33,2 +29,7 @@ /** | ||
/** | ||
* @type {boolean} Property showing whether logging will be silenced - defaults to true in a production environment | ||
*/ | ||
Git.prototype._silentLogging = /prod/.test(process.env.NODE_ENV); | ||
/** | ||
* Sets the path to a custom git binary, should either be `git` when there is an installation of git available on | ||
@@ -148,2 +149,19 @@ * the system path, or a fully qualified path to the executable. | ||
/** | ||
* Gets a function to be used for logging. | ||
* | ||
* @param {string} level | ||
* @param {string} [message] | ||
* | ||
* @returns {Function} | ||
* @private | ||
*/ | ||
Git.prototype._getLog = function (level, message) { | ||
var log = this._silentLogging ? function () {} : console[level].bind(console); | ||
if (arguments.length > 1) { | ||
log(message); | ||
} | ||
return log; | ||
}; | ||
/** | ||
* Pull the updated contents of the current repo | ||
@@ -194,2 +212,14 @@ * @param {String} [remote] | ||
/** | ||
* Disables/enables the use of the console for printing warnings and errors, by default messages are not shown in | ||
* a production environment. | ||
* | ||
* @param {boolean} silence | ||
* @returns {Git} | ||
*/ | ||
Git.prototype.silent = function (silence) { | ||
this._silentLogging = !!silence; | ||
return this; | ||
}; | ||
/** | ||
* List all tags | ||
@@ -268,3 +298,3 @@ * | ||
if (typeof args === 'string') { | ||
log.warn('Git#listRemote: args should be supplied as an array of individual arguments'); | ||
this._getLog('warn', 'Git#listRemote: args should be supplied as an array of individual arguments'); | ||
} | ||
@@ -421,3 +451,4 @@ | ||
else if (typeof args[0] === "string" || typeof args[1] === "string") { | ||
log.warn("Git#log: supplying to or from as strings is now deprecated, switch to an options configuration object"); | ||
this._getLog('warn', | ||
'Git#log: supplying to or from as strings is now deprecated, switch to an options configuration object'); | ||
opt = { | ||
@@ -632,3 +663,3 @@ from: args[0], | ||
log.error(stdErr); | ||
this._getLog('error', stdErr); | ||
this._runCache = []; | ||
@@ -635,0 +666,0 @@ then.call(this, stdErr, null); |
@@ -8,2 +8,3 @@ | ||
//}) | ||
//.silent(false) | ||
//.add('\";echo HELLO WORLD > foo\"') | ||
@@ -10,0 +11,0 @@ .listRemote('--tags', console.log.bind(console)) |
28908
629
155