Use a more tolerant regexp when splitting lines.

This commit is contained in:
André Cruz
2013-07-05 08:18:38 +01:00
parent 74b9e51cf7
commit 9f0ac51e06
2 changed files with 9 additions and 6 deletions

View File

@@ -59,7 +59,7 @@ GitFsResolver.refs = function (source) {
refs = stdout.toString()
.trim() // Trim trailing and leading spaces
.replace(/[\t ]+/g, ' ') // Standardize spaces (some git versions make tabs, other spaces)
.split(/\r?\n/); // Split lines into an array
.split(/[\r\n]+/); // Split lines into an array
// Update the refs with the actual refs
this._cache.refs.set(source, refs);

View File

@@ -51,18 +51,21 @@ GitRemoteResolver.prototype._checkout = function () {
promise = cmd('git', ['clone', this._source, '-b', branch, '--depth', 1, '--progress', '.'], { cwd: this._tempDir });
}
// Start reporting progress after 8 seconds
// Start reporting progress after a few seconds
timer = setTimeout(function () {
promise.progress(function (data) {
var lines = data.split(/\r?\n/);
var lines = data.split(/[\r\n]+/);
lines.forEach(function (line) {
if (/\d{1,3}\%/.test(line)) {
that._logger.info('progress', data);
// TODO: There are some strange chars that appear
// once in a while (\u001b[K)
// Trim also those?
that._logger.info('progress', line.trim());
}
});
});
}, 8000);
}, 10000);
return promise
// Clear timer at the end
@@ -91,7 +94,7 @@ GitRemoteResolver.refs = function (source) {
refs = stdout.toString()
.trim() // Trim trailing and leading spaces
.replace(/[\t ]+/g, ' ') // Standardize spaces (some git versions make tabs, other spaces)
.split(/\r?\n/); // Split lines into an array
.split(/[\r\n]+/); // Split lines into an array
// Update the refs with the actual refs
this._cache.refs.set(source, refs);