Return-Path: X-Original-To: apmail-cordova-dev-archive@www.apache.org Delivered-To: apmail-cordova-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9128418A86 for ; Wed, 29 Apr 2015 20:15:31 +0000 (UTC) Received: (qmail 18175 invoked by uid 500); 29 Apr 2015 20:15:31 -0000 Delivered-To: apmail-cordova-dev-archive@cordova.apache.org Received: (qmail 18136 invoked by uid 500); 29 Apr 2015 20:15:31 -0000 Mailing-List: contact dev-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list dev@cordova.apache.org Received: (qmail 18120 invoked by uid 99); 29 Apr 2015 20:15:31 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Apr 2015 20:15:31 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id E266EE0984; Wed, 29 Apr 2015 20:15:30 +0000 (UTC) From: nikhilkh To: dev@cordova.apache.org Reply-To: dev@cordova.apache.org References: In-Reply-To: Subject: [GitHub] cordova-medic pull request: [CB-8870] Consolidating medic code. Content-Type: text/plain Message-Id: <20150429201530.E266EE0984@git1-us-west.apache.org> Date: Wed, 29 Apr 2015 20:15:30 +0000 (UTC) Github user nikhilkh commented on a diff in the pull request: https://github.com/apache/cordova-medic/pull/47#discussion_r29375808 --- Diff: bin/medic.js --- @@ -39,9 +65,109 @@ var argv = optimist .argv; // helpers +function killTasks(taskNames) { + + if (!taskNames || taskNames.length < 1) { + console.warn("no tasks to kill"); + return; + } + + if (isWindows()) { + var cli = "taskkill /F"; + var args = taskNames.map(function (name) { return "/IM \"" + name + "\""; }); + } else { + var cli = "killall"; + var args = taskNames.map(function (name) { return "\"" + name + "\""; }); + } + + var command = cli + " " + args.join(" "); + medicLog("running the following command:"); + medicLog(" " + command); + + shelljs.exec(command, {silent: false, async: true}, function (returnCode, output) { + if (returnCode !== 0) { + console.warn("WARNING: kill command returned " + returnCode); + } + }); +} + function fatal(message) { - console.error("ERROR: " + message); - process.exit(1); + console.error("FATAL: " + message); + process.exit(ERROR); +} + +function medicLog(message) { + console.log("\033[32m[MEDIC LOG]\033[m " + message); +} + +function currentMillisecond() { + // NOTE: + // coercing a Date to a Number returns + // the Date's representation in milliseconds + return Number(new Date()); +} + +function generateBuildID() { + var components = [MEDIC_BUILD_PREFIX, currentMillisecond()]; + return components.join("-"); +} + +function tasksOnPlatform(platformName) { + switch (platformName) { + case WINDOWS: + return ["WWAHost.exe"]; + case WP8: + return ["Xde.exe"]; + case IOS: + return ["iOS Simulator"]; + case ANDROID: + if (isWindows()) { + return ["emulator-arm.exe", "adb.exe"]; + } else { + return ["emulator64-x86"]; + } + case BLACKBERRY: + return []; + default: + fatal("unknown platform " + platformName); + } +} + +function cloneProject(projectName, projectsConfig) { + + var project = projectsConfig[projectName]; + var codebase = project.codebases[project.codebase]; + var command = "git clone " + codebase.repo + " --branch=" + codebase.branch + " --depth 1" + + shelljs.exec(command, {silent: false, async: true}, function (returnCode, output) { + if (returnCode !== 0) { + fatal("command \"" + command + "\" failed with code " + returnCode); --- End diff -- It will be nice to provide the `output` for diagnostics of why it failed --- 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