Skip to content

Commit

Permalink
Address the PR Review
Browse files Browse the repository at this point in the history
  • Loading branch information
umutuzgur committed Jul 4, 2019
1 parent 08ffc05 commit e22f3c8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
1 change: 0 additions & 1 deletion lib/device-log/ios-log.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class IOSLog extends EventEmitter {
constructor () {
super();
this.logs = [];
this.logRow = '';
this.logIdxSinceLastRequest = -1;
this.maxBufferSize = MAX_LOG_ENTRIES_COUNT;
}
Expand Down
21 changes: 11 additions & 10 deletions lib/device-log/ios-simulator-log.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,27 @@ class IOSSimulatorLog extends IOSLog {

async finishStartingLogCapture () {
if (!this.proc) {
log.errorAndThrow('Could not capture device log');
log.errorAndThrow('Could not capture simulator log');
}
let firstLine = true;
let logRow = '';
this.proc.on('output', (stdout, stderr) => {
if (stdout) {
if (firstLine) {
if (stdout.substr(-1, 1) === '\n') {
// don't store the first line of the log because it came before the sim or device was launched
if (stdout.endsWith('\n')) {
// don't store the first line of the log because it came before the sim was launched
firstLine = false;
}
} else {
this.logRow += stdout;
if (stdout.substr(-1, 1) === '\n') {
this.onOutput();
this.logRow = '';
logRow += stdout;
if (stdout.endsWith('\n')) {
this.onOutput(logRow);
logRow = '';
}
}
}
if (stderr) {
this.onOutput('STDERR');
this.onOutput(logRow, 'STDERR');
}
});

Expand Down Expand Up @@ -102,8 +103,8 @@ class IOSSimulatorLog extends IOSLog {
return this.proc && this.proc.isRunning;
}

onOutput (prefix = '') {
const logs = this.logRow.split('\n');
onOutput (logRow, prefix = '') {
const logs = _.cloneDeep(logRow).split('\n');
for (const logLine of logs) {
if (!logLine) continue; // eslint-disable-line curly
this.broadcast(logLine);
Expand Down

0 comments on commit e22f3c8

Please sign in to comment.