Comparing version 2.10.1 to 2.10.2
'use strict'; | ||
var through = require('through2'); | ||
var Transform = require('stream').Transform; | ||
var log = require('fancy-log'); | ||
@@ -8,2 +8,14 @@ var exec = require('child_process').exec; | ||
function addFiles(files, opt, cb) { | ||
var cwd = opt.cwd || files[files.length - 1].cwd; | ||
var cmd = 'git add ' + escape(files.map(function(file) { return file.path; })) + ' ' + opt.args; | ||
var maxBuffer = opt.maxBuffer || 200 * 1024; | ||
exec(cmd, {cwd: cwd, maxBuffer: maxBuffer}, function(err, stdout, stderr) { | ||
if (err) return cb(err); | ||
if (!opt.quiet) log(stdout, stderr); | ||
cb(); | ||
}); | ||
} | ||
module.exports = function (opt) { | ||
@@ -13,30 +25,41 @@ if (!opt) opt = {}; | ||
var paths = []; | ||
var files = []; | ||
var fileCwd = process.cwd(); | ||
var maxFiles = opt.maxFiles || Infinity; | ||
var write = function(file, enc, cb) { | ||
paths.push(file.path); | ||
var that = this; | ||
files.push(file); | ||
fileCwd = file.cwd; | ||
cb(); | ||
}; | ||
if (files.length >= maxFiles) | ||
addFiles(files.splice(0, maxFiles), opt, function(err) { | ||
if (err) return cb(err); | ||
files.forEach(that.push.bind(that)); | ||
cb(); | ||
}); | ||
else | ||
cb(); | ||
} | ||
var flush = function(cb) { | ||
var cwd = opt.cwd || fileCwd; | ||
var cmd = 'git add ' + escape(paths) + ' ' + opt.args; | ||
var that = this; | ||
var maxBuffer = opt.maxBuffer || 200 * 1024; | ||
exec(cmd, {cwd: cwd, maxBuffer: maxBuffer}, function(err, stdout, stderr) { | ||
if (err) cb(err); | ||
if (!opt.quiet) log(stdout, stderr); | ||
files.forEach(that.push.bind(that)); | ||
if (files.length > 0) { | ||
addFiles(files, opt, function(err) { | ||
if (err) return cb(err); | ||
files.forEach(that.push.bind(that)); | ||
that.emit('end'); | ||
cb(); | ||
}); | ||
} else { | ||
that.emit('end'); | ||
cb(); | ||
}); | ||
}; | ||
} | ||
} | ||
return through.obj(write, flush); | ||
return new Transform({ | ||
objectMode: true, | ||
transform: write, | ||
flush: flush | ||
}); | ||
}; |
'use strict'; | ||
var log = require('fancy-log'); | ||
var template = require('lodash.template'); | ||
var _ = require('lodash'); | ||
var exec = require('child_process').exec; | ||
@@ -40,3 +40,3 @@ var escape = require('any-shell-escape'); | ||
} | ||
var templ = template(cmd)({file: message}); | ||
var templ = _.template(cmd)({file: message}); | ||
return exec(templ, {cwd: opt.cwd, maxBuffer: maxBuffer}, function(err, stdout, stderr) { | ||
@@ -43,0 +43,0 @@ if (err) return cb(err); |
{ | ||
"name": "gulp-git", | ||
"description": "Git plugin for gulp (gulpjs.com)", | ||
"version": "2.10.1", | ||
"version": "2.10.2", | ||
"homepage": "http://github.com/stevelacy/gulp-git", | ||
@@ -15,3 +15,3 @@ "repository": { | ||
"fancy-log": "^1.3.2", | ||
"lodash.template": "^4.4.0", | ||
"lodash": "^4.17.21", | ||
"plugin-error": "^1.0.1", | ||
@@ -18,0 +18,0 @@ "require-dir": "^1.0.0", |
@@ -370,3 +370,3 @@ # gulp-git | ||
`opt`: Object (optional) `{args: 'options', cwd: '/cwd/path', quiet: true, maxBuffer: 200 * 1024}` | ||
`opt`: Object (optional) `{args: 'options', cwd: '/cwd/path', quiet: true, maxBuffer: 200 * 1024, maxFiles: Infinity}` | ||
@@ -762,4 +762,19 @@ ```js | ||
#### The command line is too long. | ||
Reported [here](https://github.com/stevelacy/gulp-git/issues/201). | ||
If the `git add` command exceeds [8191 characters on Windows](https://docs.microsoft.com/en-us/troubleshoot/windows-client/shell-experience/command-line-string-limitation#more-information) you will get this error. | ||
The `add` function has an additional option: `maxFiles`. | ||
```js | ||
gulp.task('add', function(){ | ||
return gulp.src('./git-test/*') | ||
.pipe(git.add({maxFiles: 8})); | ||
}); | ||
``` | ||
## LICENSE | ||
@@ -766,0 +781,0 @@ |
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
53408
976
802
+ Addedlodash@^4.17.21
+ Addedlodash@4.17.21(transitive)
- Removedlodash.template@^4.4.0
- Removedlodash._reinterpolate@3.0.0(transitive)
- Removedlodash.template@4.5.0(transitive)
- Removedlodash.templatesettings@4.2.0(transitive)