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:44 UTC

[06/50] cordova-paramedic git commit: cleanup platformId checks and testing windows as target

cleanup platformId checks and testing windows as target


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

Branch: refs/heads/master
Commit: 51180a96edab5f7ed8ddad17178c5ec6680d46ef
Parents: 962db83
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Thu Feb 12 17:17:20 2015 -0800
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Thu Feb 12 17:17:20 2015 -0800

----------------------------------------------------------------------
 main.js | 62 ++++++++++++++++++++++++++++++------------------------------
 1 file changed, 31 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/51180a96/main.js
----------------------------------------------------------------------
diff --git a/main.js b/main.js
index 808a710..0655261 100755
--- a/main.js
+++ b/main.js
@@ -1,7 +1,7 @@
 #!/usr/bin/env node
 
 var http = require('http'),
-    //localtunnel = require('localtunnel'),
+    localtunnel = require('localtunnel'),
     parseArgs = require('minimist'),
     shell = require('shelljs'),
     fs = require('fs'),
@@ -133,41 +133,41 @@ function setConfigStartPage() {
 }
 
 function startServer() {
+
     console.log("cordova-paramedic :: starting local medic server " + platformId);
     var server = http.createServer(requestListener);
     server.listen(PORT, '127.0.0.1',function onServerConnect() {
 
-        if(platformId == "ios") {
-            console.log('platform is ios');
-            writeMedicLogUrl("http://127.0.0.1:" + PORT);
-            addAndRunPlatform();
-        }
-        else if(platformId == "android") {
-            console.log('platform is android');
-            writeMedicLogUrl("http://127.0.0.1:" + PORT);
-            addAndRunPlatform();
-        }
-        else if(platformId == "wp8") {
-            request.get('http://google.com/', function(e, res, data) {
-                if(e) {
-                    console.error("failed to detect ip address");
-                    cleanUpAndExitWithCode(1);
-                }
-                else {
-                    console.log("res.req.connection = " + res.req.connection);
-                    var ip = res.req.connection.localAddress ||
-                             res.req.socket.localAddress;
-                    console.log("Using ip : " + ip);
-                    writeMedicLogUrl("http://" + ip + ":" + PORT);
-                    addAndRunPlatform();
-                }
-            });
-        }
-        else {
-            //localtunnel(PORT, tunnelCallback); // TODO
-            console.log("platform is not supported :: " + platformId);
-            cleanUpAndExitWithCode(1);
+        switch(platformId) {
+            case "ios"     :  // intentional fallthrough
+            case "android" :
+            case "windows" :
+                writeMedicLogUrl("http://127.0.0.1:" + PORT);
+                addAndRunPlatform();
+                break;
+            case "wp8" :
+                localtunnel(PORT, tunnelCallback);
+                // request.get('http://google.com/', function(e, res, data) {
+                //     if(e) {
+                //         console.error("failed to detect ip address");
+                //         cleanUpAndExitWithCode(1);
+                //     }
+                //     else {
+                //         console.log("res.req.connection = " + res.req.connection);
+                //         var ip = res.req.connection.localAddress ||
+                //                  res.req.socket.localAddress;
+                //         console.log("Using ip : " + ip);
+                //         writeMedicLogUrl("http://" + ip + ":" + PORT);
+                //         addAndRunPlatform();
+                //     }
+                // });
+                break;
+            default :
+                console.log("platform is not supported :: " + platformId);
+                cleanUpAndExitWithCode(1);
         }
+
+        //localtunnel(PORT, tunnelCallback); // TODO
     });
 }
 


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