simple-git
Advanced tools
Comparing version 1.23.0 to 1.24.0
{ | ||
"name": "simple-git", | ||
"description": "Simple GIT interface for node.js", | ||
"version": "1.23.0", | ||
"version": "1.24.0", | ||
"author": "Steve King <steve@mydev.co>", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
@@ -102,2 +102,4 @@ # Simple Git | ||
`.checkIgnore([filepath, ...], handlerFn)` checks if filepath excluded by .gitignore rules | ||
`.listRemote([args], handlerFn)` lists remote repositories - there are so many optional arguments in the underlying | ||
@@ -104,0 +106,0 @@ `git ls-remote` call, just supply any you want to use as the optional `args` array of strings eg: `git.listRemote(['--heads', '--tags'], console.log.bind(console))`. |
@@ -751,2 +751,21 @@ (function () { | ||
/** | ||
* Check if a pathname or pathnames are excluded by .gitignore | ||
* | ||
* @param {string|string[]} pathnames | ||
* @param {Function} [then] | ||
*/ | ||
Git.prototype.checkIgnore = function (pathnames, then) { | ||
var handler = Git.trailingFunctionArgument(arguments); | ||
var command = ["check-ignore"]; | ||
if (handler !== pathnames) { | ||
command = command.concat(pathnames); | ||
} | ||
return this._run(command, function (err, data) { | ||
handler && handler(err, !err && this._parseCheckIgnore(data)); | ||
}); | ||
}; | ||
Git.prototype._rm = function (files, options, then) { | ||
@@ -871,2 +890,11 @@ return this._run(['rm', options, [].concat(files)], function (err) { | ||
/** | ||
* Parser for the `check-ignore` command - returns each | ||
* @param {string} [files] | ||
* @returns {string[]} | ||
*/ | ||
Git.prototype._parseCheckIgnore = function (files) { | ||
return files.split(/\n/g).filter(Boolean).map(function (file) { return file.trim() }); | ||
}; | ||
/** | ||
* Schedules the supplied command to be run, the command should not include the name of the git binary and should | ||
@@ -873,0 +901,0 @@ * be an array of strings passed as the arguments to the git binary. |
@@ -635,2 +635,61 @@ | ||
exports.checkIgnore = { | ||
setUp: function (done) { | ||
Instance(); | ||
done(); | ||
}, | ||
'with single excluded file specified': function (test) { | ||
git.checkIgnore('foo.log', function (err, result) { | ||
test.equals(null, err, 'not an error'); | ||
test.same(['check-ignore', 'foo.log'], theCommandRun()); | ||
test.same(['foo.log'], result); | ||
test.done(); | ||
}); | ||
closeWith('foo.log'); | ||
}, | ||
'with two excluded files specified': function (test) { | ||
git.checkIgnore(['foo.log', 'bar.log'], function (err, result) { | ||
test.equals(null, err, 'not an error'); | ||
test.same(['check-ignore', 'foo.log', 'bar.log'], theCommandRun()); | ||
test.same(['foo.log', 'bar.log'], result); | ||
test.done(); | ||
}); | ||
closeWith('foo.log\n\ | ||
bar.log\ | ||
'); | ||
}, | ||
'with no excluded files': function (test) { | ||
git.checkIgnore(['foo.log', 'bar.log'], function (err, result) { | ||
test.equals(null, err, 'not an error'); | ||
test.same(['check-ignore', 'foo.log', 'bar.log'], theCommandRun()); | ||
test.same([], result); | ||
test.done(); | ||
}); | ||
closeWith(''); | ||
}, | ||
'with spaces in file names': function (test) { | ||
git.checkIgnore('foo space .log', function (err, result) { | ||
test.equals(null, err, 'not an error'); | ||
test.same(['check-ignore', 'foo space .log'], theCommandRun()); | ||
test.same(['foo space .log'], result); | ||
test.done(); | ||
}); | ||
closeWith('\ | ||
foo space .log\ | ||
'); | ||
} | ||
}; | ||
exports.updateServerInfo = { | ||
@@ -637,0 +696,0 @@ setUp: function(done) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
64848
1522
182