Skip to content

Commit

Permalink
exec options to e.g. fix maxBuffer errors
Browse files Browse the repository at this point in the history
Default maxBuffer for exec calls is 200*1024 which may be inadequate
for many git calls.

Added option to supply the exec options and thus be able to override
the default maxBuffer option.
  • Loading branch information
Gregory Vincic committed Nov 12, 2015
1 parent 7955877 commit bb4cd7f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ If you are using git as version control you can do the following in your test:
require('mocha-jshint')({
git: {
modified: true,
commits: 2
commits: 2,
exec: {
maxBuffer: 20*1024*1024
}
}
});
```
Expand Down
8 changes: 4 additions & 4 deletions git.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = function (options, cb) {
cb(new Error('git options need to have either options.modified:true or have options.commits>0'));
}
if (options.masterDiff) {
return exec('git rev-parse --abbrev-ref HEAD', getFilesChangesInCurrentBranch);
return exec('git rev-parse --abbrev-ref HEAD', options.exec, getFilesChangesInCurrentBranch);
}
return compareLatestCommits();

Expand All @@ -27,12 +27,12 @@ module.exports = function (options, cb) {
if (options.modified) {
command += ' && git diff --name-only HEAD';
}
return exec(command, returnFiles);
return exec(command, options.exec, returnFiles);
}

function compareLatestCommits() {
var maxCount = (options.commits || 0) + 1;
return exec(format('git log --pretty=format:%h --max-count=%d', maxCount), findSHA);
return exec(format('git log --pretty=format:%h --max-count=%d', maxCount), options.exec, findSHA);
}

function findSHA(err, stdout) {
Expand All @@ -50,7 +50,7 @@ module.exports = function (options, cb) {
if (!command) {
return cb(null, []);
}
return exec(command, returnFiles);
return exec(command, options.exec, returnFiles);
}

function returnFiles(err, stdout) {
Expand Down

0 comments on commit bb4cd7f

Please sign in to comment.