From 30c49550c89c1b69c680170d2dc247eac76bd463 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 16 Feb 2017 01:24:12 +0100 Subject: push plugin --- StoneIsland/platforms/android/cordova/lib/run.js | 99 ++++++++++-------------- 1 file changed, 40 insertions(+), 59 deletions(-) mode change 100755 => 100644 StoneIsland/platforms/android/cordova/lib/run.js (limited to 'StoneIsland/platforms/android/cordova/lib/run.js') diff --git a/StoneIsland/platforms/android/cordova/lib/run.js b/StoneIsland/platforms/android/cordova/lib/run.js old mode 100755 new mode 100644 index 7f15448c..214a1e19 --- a/StoneIsland/platforms/android/cordova/lib/run.js +++ b/StoneIsland/platforms/android/cordova/lib/run.js @@ -25,63 +25,36 @@ var path = require('path'), build = require('./build'), emulator = require('./emulator'), device = require('./device'), - shell = require('shelljs'), - Q = require('q'); + Q = require('q'), + events = require('cordova-common').events; -/* - * Runs the application on a device if available. - * If no device is found, it will use a started emulator. - * If no started emulators are found it will attempt to start an avd. - * If no avds are found it will error out. - * Returns a promise. - */ - module.exports.run = function(args) { - var buildFlags = []; +function getInstallTarget(runOptions) { var install_target; - var list = false; - - for (var i=2; i 0) { - console.log('WARNING : No target specified, deploying to device \'' + device_list[0] + '\'.'); + events.emit('warn', 'No target specified, deploying to device \'' + device_list[0] + '\'.'); install_target = device_list[0]; } else { - console.log('WARNING : No target specified, deploying to emulator'); + events.emit('warn', 'No target specified and no devices found, deploying to emulator'); install_target = '--emulator'; } }); @@ -137,17 +110,25 @@ var path = require('path'), }); }); }).then(function(resolvedTarget) { - return build.run(buildFlags, resolvedTarget).then(function(buildResults) { + // Better just call self.build, but we're doing some processing of + // build results (according to platformApi spec) so they are in different + // format than emulator.install expects. + // TODO: Update emulator/device.install to handle this change + return build.run.call(self, runOptions, resolvedTarget) + .then(function(buildResults) { if (resolvedTarget.isEmulator) { - return emulator.install(resolvedTarget, buildResults); + return emulator.wait_for_boot(resolvedTarget.target) + .then(function () { + return emulator.install(resolvedTarget, buildResults); + }); } return device.install(resolvedTarget, buildResults); }); }); }; -module.exports.help = function(args) { - console.log('Usage: ' + path.relative(process.cwd(), args[1]) + ' [options]'); +module.exports.help = function() { + console.log('Usage: ' + path.relative(process.cwd(), process.argv[1]) + ' [options]'); console.log('Build options :'); console.log(' --debug : Builds project in debug mode'); console.log(' --release : Builds project in release mode'); -- cgit v1.2.3-70-g09d2