Skip to content

Commit

Permalink
fix(regex): fix terminal output regex
Browse files Browse the repository at this point in the history
  • Loading branch information
jkuri committed Aug 8, 2017
1 parent bd485e4 commit 547203b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/app/components/app-terminal/app-terminal.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand All @@ -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) => {
Expand Down
3 changes: 3 additions & 0 deletions src/app/styles/terminal.sass
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
height: 24px

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

span
font-size: 12px
Expand Down

0 comments on commit 547203b

Please sign in to comment.