Open fold if folded command returns an error

This commit is contained in:
Piotr Sarnacki 2012-12-05 00:33:26 +01:00
parent fc40190c29
commit 4e7329f638
5 changed files with 45 additions and 4 deletions

View File

@ -68,6 +68,7 @@ Travis.Store = DS.Store.extend
{ id: id, clientId: clientId }
receive: (event, data) ->
console.log event, data if event == 'job:log'
[name, type] = event.split(':')
mappings = @adapter.get('mappings')

View File

@ -191,6 +191,11 @@
else
this.$('#log').append(line)
if payload.openFold
this.$("#log .fold.#{payload.openFold}:last").
removeClass('show-first-line').
addClass('open')
if payload.foldEnd
this.$("#log .fold.#{payload.fold}:last").removeClass('show-first-line')

File diff suppressed because one or more lines are too long

View File

@ -70,6 +70,14 @@ FOLDS = [
else if payload.number != 1
payload.append = true
if payload.foldContinuation && payload.content.match(/Done. Build script exited with:/)
# script ended, but fold is still closed, which most probably means
# error, end the fold and open it.
# TODO: we need log marks to make it easier
payload.foldContinuation = null
payload.openFold = payload.fold
payload.fold = null
result.pushObject payload
if currentFold
@ -94,6 +102,9 @@ FOLDS = [
log = log.replace /\r\n/g, '\n'
lines = log.split(/(\n)/)
if lines.slice(-1)[0] == ''
lines.popObject()
result = []
for line in lines
result.pushObjects line.split(/(\r)/)

View File

@ -7,7 +7,8 @@ ansiparse = function (str) {
matchingText = '',
ansiState = [],
result = [],
state = {};
state = {},
eraseChar;
//
// General workflow for this thing is:
@ -20,6 +21,29 @@ ansiparse = function (str) {
// In further steps we hope it's all going to be fine. It usually is.
//
//
// Erases a char from the output
//
eraseChar = function () {
var index, text;
if (matchingText.length) {
matchingText = matchingText.substr(0, matchingText.length - 1);
}
else if (result.length) {
index = result.length - 1;
text = result[index].text;
if (text.length === 1) {
//
// A result bit was fully deleted, pop it out to simplify the final output
//
result.pop();
}
else {
result[index].text = text.substr(0, text.length - 1);
}
}
};
for (var i = 0; i < str.length; i++) {
if (matchingControl != null) {
if (matchingControl == '\033' && str[i] == '\[') {
@ -111,7 +135,9 @@ ansiparse = function (str) {
if (str[i] == '\033') {
matchingControl = str[i];
}
else if (str[i] == '\u0008') {
eraseChar();
}
else {
matchingText += str[i];
@ -158,4 +184,3 @@ if (typeof module == "object" && typeof window == "undefined") {
module.exports = ansiparse;
}