You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2016/03/04 01:35:57 UTC

[19/50] cordova-paramedic git commit: added justbuild param, set to truthy to exit without running installing all the tests. This closes #12

added justbuild param, set to truthy to exit without running installing all the tests. This closes #12


Project: http://git-wip-us.apache.org/repos/asf/cordova-paramedic/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-paramedic/commit/d83fdbcc
Tree: http://git-wip-us.apache.org/repos/asf/cordova-paramedic/tree/d83fdbcc
Diff: http://git-wip-us.apache.org/repos/asf/cordova-paramedic/diff/d83fdbcc

Branch: refs/heads/master
Commit: d83fdbcc024c5f48a62f1863cee8c05bf3bc6637
Parents: aa7d1f6
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Fri Mar 20 15:31:41 2015 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Fri Mar 20 15:33:56 2015 -0700

----------------------------------------------------------------------
 main.js | 122 +++++++++++++++++++++++++++++++++++++----------------------
 1 file changed, 76 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/d83fdbcc/main.js
----------------------------------------------------------------------
diff --git a/main.js b/main.js
index 06a1513..c23f24d 100755
--- a/main.js
+++ b/main.js
@@ -10,28 +10,27 @@ var http = require('http'),
 
 var tunneledUrl = "";
 var PORT = 8008;
+var TIMEOUT = 10 * 60 * 1000; // 10 minutes in msec - this will become a param
 var USAGE = "Error missing args. \n Usage: $cordova-paramedic " +
             "  --platform CORDOVA-PLATFORM --plugin PLUGIN-PATH [--port PORT]";
+
 var TEMP_PROJECT_PATH = "tmp";
 var storedCWD = process.cwd();
-var TIMEOUT = 10 * 60 * 1000; // 10 minutes in msec - this will become a param
+
+var JustBuild = false;
 
 var plugin,platformId;
 
-run();
 
-// main program here 
-function run() {
+(function run_main() { // main program here 
     init();
     createTempProject();
     installPlugins();
     startServer();
-}
+})();
 
 function init() {
-    var argv = parseArgs(process.argv.slice(2),{default:{
-        timeout:TIMEOUT
-    }});
+    var argv = parseArgs(process.argv.slice(2));
 
     if(!argv.platform || !argv.plugin) {
         console.log(USAGE);
@@ -40,10 +39,11 @@ function init() {
 
     platformId = argv.platform;
     plugin = argv.plugin;
-    // TODO: validate that it is a number
-    PORT = argv.port || PORT;
-
 
+    // TODO: validate that port is a number
+    PORT = argv.port || PORT;
+    JustBuild = argv.justbuild || JustBuild; 
+    TIMEOUT = argv.timeout || TIMEOUT;
 
     var cordovaResult = shell.exec('cordova --version', {silent:true});
     if(cordovaResult.code) {
@@ -70,47 +70,72 @@ function installPlugins() {
         return;
     }
 
-    console.log("cordova-paramedic :: installing " + path.join(plugin,'tests'));
-    installExitCode = shell.exec('cordova plugin add ' + path.join(plugin,'tests'),
-                                 {silent:true}).code;
-    if(installExitCode != 0) {
-        console.error('Failed to find /tests/ for plugin : ' + plugin);
-        cleanUpAndExitWithCode(1);
-        return;
-    }
+    if(!JustBuild) { 
+        // we only install the test stuff if needed
+        console.log("cordova-paramedic :: installing " + path.join(plugin,'tests'));
+        installExitCode = shell.exec('cordova plugin add ' + path.join(plugin,'tests'),
+                                     {silent:true}).code;
+        if(installExitCode != 0) {
+            console.error('Failed to find /tests/ for plugin : ' + plugin);
+            cleanUpAndExitWithCode(1);
+            return;
+        }
 
-    console.log("cordova-paramedic :: installing plugin-test-framework");
-    installExitCode = shell.exec('cordova plugin add https://github.com/apache/cordova-plugin-test-framework',
-                                 {silent:true}).code;
-    if(installExitCode != 0) {
-        console.error('cordova-plugin-test-framework');
-        cleanUpAndExitWithCode(1);
-        return;
+        console.log("cordova-paramedic :: installing plugin-test-framework");
+        installExitCode = shell.exec('cordova plugin add https://github.com/apache/cordova-plugin-test-framework',
+                                     {silent:true}).code;
+        if(installExitCode != 0) {
+            console.error('cordova-plugin-test-framework');
+            cleanUpAndExitWithCode(1);
+            return;
+        }
     }
-
 }
 
 function addAndRunPlatform() {
-    setConfigStartPage();
-    console.log("cordova-paramedic :: adding platform");
-    shell.exec('cordova platform add ' + platformId,{silent:true});
-    shell.exec('cordova prepare',{silent:true});
-    // limit runtime to TIMEOUT msecs
-    setTimeout(function(){
-        console.error("This test seems to be blocked :: timeout exceeded. Exiting ...");
-        cleanUpAndExitWithCode(1);
-    },(TIMEOUT));
-
-    shell.exec('cordova emulate ' + platformId.split("@")[0] + " --phone",
-        {async:true,silent:true},
-        function(code,output){
-            if(code != 0) {
-                console.error("Error: cordova emulate return error code " + code);
-                console.log("output: " + output);
-                cleanUpAndExitWithCode(1);
+
+    if(JustBuild) {
+        console.log("cordova-paramedic :: adding platform");
+        shell.exec('cordova platform add ' + platformId,{silent:true});
+        shell.exec('cordova prepare',{silent:true});
+        console.log("building ...");
+        shell.exec('cordova build ' + platformId.split("@")[0],
+            {async:true,silent:true},
+            function(code,output){
+                if(code != 0) {
+                    console.error("Error: cordova build returned error code " + code);
+                    console.log("output: " + output);
+                    cleanUpAndExitWithCode(1);
+                }
+                else {
+                    console.log("lookin' good!");
+                    cleanUpAndExitWithCode(0);
+                }
             }
-        }
-    );
+        );
+    }
+    else {
+        setConfigStartPage();
+        console.log("cordova-paramedic :: adding platform");
+        shell.exec('cordova platform add ' + platformId,{silent:true});
+        shell.exec('cordova prepare',{silent:true});
+        // limit runtime to TIMEOUT msecs
+        setTimeout(function(){
+            console.error("This test seems to be blocked :: timeout exceeded. Exiting ...");
+            cleanUpAndExitWithCode(1);
+        },(TIMEOUT));
+
+        shell.exec('cordova emulate ' + platformId.split("@")[0] + " --phone",
+            {async:true,silent:true},
+            function(code,output){
+                if(code != 0) {
+                    console.error("Error: cordova emulate return error code " + code);
+                    console.log("output: " + output);
+                    cleanUpAndExitWithCode(1);
+                }
+            }
+        );
+    }
 }
 
 function cleanUpAndExitWithCode(exitCode) {
@@ -142,6 +167,11 @@ function setConfigStartPage() {
 
 function startServer() {
 
+    if(JustBuild) {
+        addAndRunPlatform();
+        return;
+    }
+
     console.log("cordova-paramedic :: starting local medic server " + platformId);
     var server = http.createServer(requestListener);
     server.listen(PORT, '127.0.0.1',function onServerConnect() {


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