cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nikhilkh <...@git.apache.org>
Subject [GitHub] cordova-medic pull request: [CB-8870] Consolidating medic code.
Date Wed, 29 Apr 2015 20:20:47 GMT
Github user nikhilkh commented on a diff in the pull request:

    https://github.com/apache/cordova-medic/pull/47#discussion_r29376311
  
    --- Diff: bin/medic.js ---
    @@ -109,10 +441,175 @@ function commandClean() {
     
         // if loop exited without success, return an error
         if (success === false) {
    -        fatal("failed to remove files");
    +        console.error("failed to remove files");
    +        process.exitCode = ERROR;
    +    } else {
    +        medicLog("cleanup succeeded");
         }
     }
     
    +function commandKill() {
    +
    +    // get command-specific args
    +    argv = optimist
    +        .usage("Usage: $0 --platform {platform}")
    +        .demand("platform")
    +        .argv;
    +
    +    var platform = argv.platform;
    +
    +    // get and kill platform tasks
    +    var platformTasks = tasksOnPlatform(platform)
    +    killTasks(platformTasks);
    +}
    +
    +function commandCheckout() {
    +
    +    // get command-specific args
    +    argv = optimist
    +        .usage("Usage: $0 --config {path} --exclude {name[,name[,...]]}")
    +        .demand("config")
    +        .argv;
    +
    +    var configFile    = argv.config;
    +    var excludedNames = [];
    +
    +    // parse excludes
    +    if (argv.exclude) {
    +        excludedNames = argv.exclude.split(",");
    +    }
    +
    +    // read in config
    +    var projectsConfig = JSON.parse(fs.readFileSync(configFile, DEFAULT_ENCODING));
    +
    +    // clone all projects in the config
    +    for (var projectName in projectsConfig) {
    +        if (excludedNames.indexOf(projectName) === (-1)) {
    +            cloneProject(projectName, projectsConfig);
    +        }
    +    }
    +}
    +
    +function commandRun() {
    +
    +    // get command-specific args
    +    argv = optimist
    +        .usage("Usage: $0 {options}")
    +        .demand("platform")
    +        .demand("couchdb")
    +        .default("entry", DEFAULT_APP_ENTRY)
    +        .default("id", generateBuildID())
    +        .default("app", DEFAULT_APP_PATH)
    +        .default("timeout", DEFAULT_TIMEOUT).describe("timeout", "timeout in seconds")
    +        .default("winvers", DEFAULT_WINDOWS_VERSION).describe("winvers", "[" + WINDOWS_VERSION_CHOICES.join("|")
+ "]")
    +        .argv;
    +
    +    var platform   = argv.platform;
    +    var buildId    = argv.id;
    +    var appPath    = argv.app;
    +    var couchdbURI = argv.couchdb;
    +    var entryPoint = argv.entry;
    +    var timeout    = argv.timeout;
    +
    +    var cli = getLocalCLI();
    +
    +    // check that the app exists
    +    if (!fs.existsSync(appPath)) {
    +        fatal("app " + appPath + " does not exist");
    +    }
    +
    +    // modify the app to run autonomously
    +    createMedicJson(appPath, buildId, couchdbURI);
    +    setEntryPoint(appPath, entryPoint);
    +    addURIToWhitelist(appPath, couchdbURI);
    +
    +    // do platform-specific modifications
    +    var platformArgs = "";
    +    if (platform === ANDROID) {
    +        platformArgs = androidSpecifics(argv);
    +    } else if (platform === WINDOWS) {
    +        platformArgs = windowsSpecifics(argv);
    +    } else if (platform === WP8) {
    +        platformArgs = wp8Specifics(argv);
    +    }
    +
    +    // enter the app directory
    +    shelljs.pushd(appPath);
    +
    +    // build the code (synchronously)
    +    var buildCommand = cli + " build " + platform + " -- " + platformArgs;
    +    medicLog("building:");
    +    medicLog("    " + buildCommand);
    +
    +    var result = shelljs.exec(buildCommand, {silent: false, async: false});
    +    if (result.code != 0) {
    +        console.error("BUILD FAILED:\n" + result.output);
    +        fatal("build failed");
    +    }
    +
    +    // run the code (asynchronously)
    +    var runCommand = cli + " run " + platform + " -- " + platformArgs;
    +    medicLog("running:");
    +    medicLog("    " + runCommand);
    +
    +    shelljs.exec(runCommand, {silent: false, async: true}, function (returnCode, output)
{
    +        if (returnCode != 0) {
    --- End diff --
    
    `returncode` is not always set correctly - cordova build & run.


---
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