Permalink
Browse files

fix(regex): fix terminal output regex

  • Loading branch information...
jkuri committed Aug 8, 2017
1 parent bd485e4 commit 547203b9febb65384822b344e882b3ad456ff848
Showing with 7 additions and 8 deletions.
  1. +4 −8 src/app/components/app-terminal/app-terminal.component.ts
  2. +3 −0 src/app/styles/terminal.sass
@@ -50,14 +50,12 @@ export class AppTerminalComponent implements OnInit {
this.commands = [];
} else {
const output: string = this.au.ansi_to_html(this.data);
const regex = /<span(.*)==&gt;(.*)<\/span>/g;
const regexLinux = /<span(.*)==>(.*)<\/span>/g;
const regex = /==[&gt;|>](.*)/g;
let match;
let commands: string[] = [];

if (output.match(regex) || output.match(regexLinux)) {
if (output.match(regex)) {
while (match = regex.exec(output)) { commands.push(match[0]); }
while (match = regexLinux.exec(output)) { commands.push(match[0]); }

if (commands.length > 1) {
this.commands = [];
@@ -72,16 +70,14 @@ export class AppTerminalComponent implements OnInit {
re = new RegExp('(' + c + ')' + '[\\s\\S]+');
}

console.log(re);

return acc.concat({
command: curr,
command: curr.trim(),
visible: i === commands.length - 1 ? true : false,
output: output.match(re) && output.match(re)[2] ? output.match(re)[2].trim() : ''
});
}, this.commands);
} else {
this.commands[this.commands.length - 1].output += output;
this.commands[this.commands.length - 1].output += output.trim();
}

this.commands = this.commands.map((cmd, i) => {
@@ -42,6 +42,9 @@
height: 24px

.command
font-size: 12px
color: #FFEE58
font-weight: bold

span
font-size: 12px

0 comments on commit 547203b

Please sign in to comment.