diff --git a/packages/boilerplate-generator/boilerplate_web.cordova.html b/packages/boilerplate-generator/boilerplate_web.cordova.html
index da6e53ff2c..d4cd0be029 100644
--- a/packages/boilerplate-generator/boilerplate_web.cordova.html
+++ b/packages/boilerplate-generator/boilerplate_web.cordova.html
@@ -21,7 +21,7 @@
}
-
+
{{#each js}}
{{/each}}
{{#each additionalStaticJs}}
diff --git a/packages/meteor-platform/package.js b/packages/meteor-platform/package.js
index 18f69fcb60..c498c87b1d 100644
--- a/packages/meteor-platform/package.js
+++ b/packages/meteor-platform/package.js
@@ -68,5 +68,5 @@ Package.on_use(function(api) {
Cordova.depends({
'org.apache.cordova.device': '0.2.11',
- 'com.meteor.cordova-update': 'https://github.com/meteor/com.meteor.cordova-update/tarball/c3c3192ca318105c7aca6627a42e9a4b0ffb1f36'
+ 'com.meteor.cordova-update': 'https://github.com/meteor/com.meteor.cordova-update/tarball/92fe99b7248075318f6446b288995d4381d24cd2'
});
diff --git a/tools/commands-cordova.js b/tools/commands-cordova.js
index 278d0237dc..b01308bfa6 100644
--- a/tools/commands-cordova.js
+++ b/tools/commands-cordova.js
@@ -2226,7 +2226,7 @@ main.registerCommand({
if (args.length) {
var arg = args[0];
if (arg == "adb") {
- Android.runAdb(args.slice(1), { pipeOutput: true, detached: true, stdio: ['inherit', 'inherit', 'inherit']});
+ Android.runAdb(args.slice(1), { pipeOutput: true, detached: true, stdio: 'inherit' });
}
}
diff --git a/tools/commands.js b/tools/commands.js
index 38bf5d4c0d..e509379aca 100644
--- a/tools/commands.js
+++ b/tools/commands.js
@@ -256,7 +256,7 @@ function doRunCommand (options) {
}
// If we are targeting the remote devices, warn about ports and same network
- if (_.intersection(options.args, ['ios-device', 'android-device']).length) {
+ if (utils.runOnDevice(options)) {
cordova.verboseLog('A run on a device requested');
var warning = [
"WARNING: You are testing your app on a remote device.",
diff --git a/tools/processes.js b/tools/processes.js
index e208733f4b..ff9955f83c 100644
--- a/tools/processes.js
+++ b/tools/processes.js
@@ -49,6 +49,7 @@ _.extend(RunCommand.prototype, {
});
self.process.on('error', function (err) {
+ Console.debug("Error while running command", err);
self.exitError = err;
self.exitFuture.isResolved() || self.exitFuture['throw'](err);
});
diff --git a/tools/tests/utils-tests.js b/tools/tests/utils-tests.js
index fa58768467..c8f7808056 100644
--- a/tools/tests/utils-tests.js
+++ b/tools/tests/utils-tests.js
@@ -127,14 +127,34 @@ selftest.define("parse url", function () {
});
selftest.define('get mobile server argument for meteor run', function () {
- // meteor run -p 3000 => mobile server should be :3000
+ // on emulator
+
+ // meteor run -p 3000
+ // => mobile server should be localhost:3000
selftest.expectEqual(utils.mobileServerForRun({
port: "3000"
- }), { host: utils.ipAddress(), port: "3000", protocol: "http://" });
+ }), { host: "localhost", port: "3000", protocol: "http://" });
- // meteor run -p example.com:3000 => mobile server should be :3000
+ // meteor run -p example.com:3000
+ // => mobile server should be localhost:3000
selftest.expectEqual(utils.mobileServerForRun({
port: "example.com:3000"
+ }), { host: "localhost", port: "3000", protocol: "http://" });
+
+ // on device
+
+ // meteor run -p 3000 on device
+ // => mobile server should be :3000
+ selftest.expectEqual(utils.mobileServerForRun({
+ port: "3000",
+ args: ["ios-device"]
+ }), { host: utils.ipAddress(), port: "3000", protocol: "http://" });
+
+ // meteor run -p example.com:3000 on device
+ // => mobile server should be :3000
+ selftest.expectEqual(utils.mobileServerForRun({
+ port: "example.com:3000",
+ args: ["android-device"]
}), { host: utils.ipAddress(), port: "3000", protocol: "http://" });
// meteor run -p example.com:3000 --mobile-server 4000 => error, mobile
diff --git a/tools/utils.js b/tools/utils.js
index 74384ac194..e10dae3d13 100644
--- a/tools/utils.js
+++ b/tools/utils.js
@@ -638,6 +638,12 @@ _.extend(exports.Patience.prototype, {
}
});
+// Are we running on device?
+exports.runOnDevice = function (options) {
+ return !! _.intersection(options.args,
+ ['ios-device', 'android-device']).length;
+};
+
// Given the options for a 'meteor run' command, returns a parsed URL ({
// host: *, protocol: *, port: * }. The rules for --mobile-server are:
// * If you don't specify anything for --mobile-server, then it
@@ -645,6 +651,12 @@ _.extend(exports.Patience.prototype, {
// * If you specify something for --mobile-server, we use that,
// defaulting to http:// as the protocol and 80 or 443 as the port.
exports.mobileServerForRun = function (options) {
+ // we want to do different IP generation depending on whether we
+ // are running for a device or simulator
+ options = _.extend({}, options, {
+ runOnDevice: exports.runOnDevice(options)
+ });
+
var parsedUrl = parseUrl(options.port);
if (! parsedUrl.port) {
throw new Error("--port must include a port.");
@@ -652,9 +664,26 @@ exports.mobileServerForRun = function (options) {
// XXX COMPAT WITH 0.9.2.2 -- the 'mobile-port' option is deprecated
var mobileServer = options["mobile-server"] || options["mobile-port"];
- var parsedMobileServer;
- if (! mobileServer) {
+
+ // if we specified a mobile server, use that
+
+ if (mobileServer) {
+ var parsedMobileServer = parseUrl(mobileServer, {
+ protocol: "http://"
+ });
+
+ if (! parsedMobileServer.host) {
+ throw new Error("--mobile-server must specify a hostname.");
+ }
+
+ return parsedMobileServer;
+ }
+
+
+ // if we are running on a device, use the auto-detected IP
+
+ if (options.runOnDevice) {
var myIp = ipAddress();
if (! myIp) {
throw new Error(
@@ -663,20 +692,19 @@ exports.mobileServerForRun = function (options) {
"to with --mobile-server.");
}
- parsedMobileServer = {
+ return {
host: myIp,
port: parsedUrl.port,
protocol: "http://"
};
- } else {
- parsedMobileServer = parseUrl(mobileServer, {
- protocol: "http://"
- });
-
- if (! parsedMobileServer.host) {
- throw new Error("--mobile-server must specify a hostname.");
- }
}
- return parsedMobileServer;
+
+ // we are running a simulator, use localhost:3000
+
+ return {
+ host: "localhost",
+ port: parsedUrl.port,
+ protocol: "http://"
+ };
};