diff --git a/lib/help_run.js b/lib/help_run.js index 5161af8..3e6e447 100644 --- a/lib/help_run.js +++ b/lib/help_run.js @@ -420,24 +420,21 @@ class Helper { } fs.watchFile(playerLog, () => { - fs.createReadStream(playerLog) - .on('data', output => { - const matches = output.toString().trim().match(/\w+ \d+ \d+\:\d+\:\d+ .+/g); + var stream = new fs.createReadStream(playerLog); + stream.on('data', output => { + const matches = output.toString().trim().match(/\d+-\d+-\d+T\d+:\d+:\d+Z\ \[Genymotion Player:\d+\] \[\w+\] Device booted in .+/g); if (matches) { const // try to grab the last line from the file lastLine = matches[matches.length - 1], // capture the timestamp that is prefixed in the log per line - dateTime = lastLine.match(/^\w+ \d+|\d+\:\d+\:\d+/g), - // create a valid date string for Date.parse; need to add the current year after date - fullDateTime = `${dateTime[0]} ${new Date().getFullYear()} ${dateTime[1]}`; + dateTime = lastLine.match(/^\d+-\d+-\d+T\d+:\d+:\d+Z/g); const - logTime = Date.parse(fullDateTime), + logTime = Date.parse(dateTime), deltaTime = Date.now() - logTime; - - // if the timestamp is within 10 second of current time and log ends with 'Connected' (launched), then move to next task - if (deltaTime <= 10000 && /Connected$/g.test(lastLine)) { + // if the timestamp is within 10 second of current time and log ends with 'Device booted in' (launched), then move to next task + if (deltaTime <= 10000 && /Device booted in .+/g.test(lastLine)) { fs.unwatchFile(playerLog); resolve(); } @@ -521,4 +518,4 @@ function _spawnConvert(cmd, flags) { default: // macOS return cmd; } -} \ No newline at end of file +}