removed colors from the web view logs sectino

This commit is contained in:
Kasra Bigdeli
2018-12-30 19:47:55 -08:00
parent 7c942f8d81
commit cd020771d0
2 changed files with 14 additions and 2 deletions
@@ -3,6 +3,7 @@ import ApiComponent from "../../../global/ApiComponent";
import Toaster from "../../../../utils/Toaster";
import ClickableLink from "../../../global/ClickableLink";
import { Input, Icon, Alert, Row, Spin } from "antd";
import Utils from "../../../../utils/Utils";
export default class BuildLogsView extends ApiComponent<
{
@@ -44,7 +45,7 @@ export default class BuildLogsView extends ApiComponent<
self.setState({ expandedLogs: true });
}
let lines = logInfo.logs.lines;
let lines = logInfo.logs.lines as string[];
let firstLineNumberOfLogs = logInfo.logs.firstLineNumber;
let firstLinesToPrint = 0;
if (firstLineNumberOfLogs > self.state.lastLineNumberPrinted) {
@@ -68,8 +69,10 @@ export default class BuildLogsView extends ApiComponent<
let lineAdded = false;
let buildLogs = self.state.buildLogs;
const ansiRegex = Utils.getAnsiColorRegex();
for (let i = firstLinesToPrint; i < lines.length; i++) {
buildLogs += (lines[i] || "").trim() + "\n";
const newLine = (lines[i] || "").trim().replace(ansiRegex, "");
buildLogs += newLine + "\n";
lineAdded = true;
}
+9
View File
@@ -11,5 +11,14 @@ export default {
v = c === "x" ? r : (r & 0x3) | 0x8;
return v.toString(16);
});
},
getAnsiColorRegex() {
const pattern = [
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\\u0007)",
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"
].join("|");
return new RegExp(pattern, "g");
}
};