cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From riknoll <...@git.apache.org>
Subject [GitHub] cordova-paramedic pull request: Choose Target and use it for loggi...
Date Fri, 06 May 2016 23:01:59 GMT
Github user riknoll commented on a diff in the pull request:

    https://github.com/apache/cordova-paramedic/pull/5#discussion_r62402348
  
    --- Diff: lib/utils/utilities.js ---
    @@ -40,6 +40,57 @@ function getSimulatorsFolder() {
         return simulatorsFolderPath;
     }
     
    +function getDeviceId() {
    +    var findSimCommand = "cordova run --list --emulator | grep ^iPhone | tail -n1";
    +
    +    logger.info("running:");
    +    logger.info("    " + findSimCommand);
    +
    +    var findSimResult = shelljs.exec(findSimCommand, {silent: true, async: false});
    +
    +    if (findSimResult.code > 0) {
    +        logger.error("Failed to find simulator we deployed to");
    +        return undefined;
    +    }
    +
    +    return findSimResult.output;
    +}
    +
    +function getSimulatorId(findSimResult) {
    +    var split = findSimResult.split(", ");
    +
    +    // Format of the output is "iPhone-6s-Plus, 9.1"
    +    // Extract the device name and the version number
    +    var device = split[0].replace(/-/g, " ").trim();
    +    var version = split[1].trim();
    +
    +    // Next, figure out the ID of the simulator we found
    +    var instrCommand = "instruments -s devices | grep ^iPhone";
    +    logger.info("running:");
    +    logger.info("    " + instrCommand);
    +
    +    var instrResult = shelljs.exec(instrCommand, {silent: true, async: false});
    +
    +    if (instrResult.code > 0) {
    +        logger.error("Failed to get the list of simulators");
    +        return undefined;
    +    }
    +
    +    // This matches <device> (<version>) [<simulator-id>]
    +    var simIdRegex = /^([a-zA-Z\d ]+) \(([\d.]+)\) \[([a-zA-Z\d\-]*)\].*$/;
    +
    +    var simId = null;
    +    var lines = instrResult.output.split(/\n/);
    +    lines.forEach(function(line) {
    +        var simIdMatch = simIdRegex.exec(line);
    +        if (simIdMatch && simIdMatch.length === 4 && simIdMatch[1] ===
device && simIdMatch[2] === version) {
    +            simId = encodeURIComponent(simIdMatch[3]);
    +        }
    +    });
    +
    +    return simId;
    +}
    +
     function getSimId() {
    --- End diff --
    
    Should `getSimID` be deleted now that you've defined `getSimulatorId` and `getDeviceId`?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


Mime
View raw message