You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ja...@apache.org on 2018/11/24 19:52:57 UTC

[cordova-paramedic] 01/01: get server ip automatically (#3)

This is an automated email from the ASF dual-hosted git repository.

janpio pushed a commit to branch johanlantz-get_server_ip
in repository https://gitbox.apache.org/repos/asf/cordova-paramedic.git

commit 0f1362f6dced599f2bd3e864e8b55153f9c28410
Author: johanlantz <il...@gmail.com>
AuthorDate: Wed Jun 13 18:07:12 2018 +0200

    get server ip automatically (#3)
---
 lib/ParamedicConfig.js | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/lib/ParamedicConfig.js b/lib/ParamedicConfig.js
index ad8d627..2a4aacb 100644
--- a/lib/ParamedicConfig.js
+++ b/lib/ParamedicConfig.js
@@ -30,6 +30,8 @@ var BROWSERIFY_ARG                         = '--browserify ';
 var DEFAULT_CLI                            = 'cordova'; // use globally installed cordova by default
 
 var util = require('./utils').utilities;
+var ip = require('ip');
+var logger = require('./utils').logger;
 
 function ParamedicConfig(json) {
     this._config = json;
@@ -152,7 +154,14 @@ ParamedicConfig.prototype.setPlugins = function (plugins) {
 };
 
 ParamedicConfig.prototype.getExternalServerUrl = function () {
-    return this._config.externalServerUrl;
+    if (this._config.externalServerUrl) {
+        return this._config.externalServerUrl;
+    } else {
+       // Android emulator defaults to 10.0.0.2 for some reason. If that is needed, it must be passed using the externalServerUrl parameter
+        var serverIp = "http://" + ip.address();
+        logger.info("Using local server address = " + serverIp);
+        return serverIp;
+    }
 };
 
 ParamedicConfig.prototype.isVerbose = function () {


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