Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Genymotion launch script (Genymotion 2.10 and higher) #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions lib/help_run.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -521,4 +518,4 @@ function _spawnConvert(cmd, flags) {
default: // macOS
return cmd;
}
}
}