You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by al...@apache.org on 2016/12/02 10:37:31 UTC
cordova-paramedic git commit: CB-12209 Async app uninstall
Repository: cordova-paramedic
Updated Branches:
refs/heads/master 39e3bc86d -> 5dea2407f
CB-12209 Async app uninstall
Project: http://git-wip-us.apache.org/repos/asf/cordova-paramedic/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-paramedic/commit/5dea2407
Tree: http://git-wip-us.apache.org/repos/asf/cordova-paramedic/tree/5dea2407
Diff: http://git-wip-us.apache.org/repos/asf/cordova-paramedic/diff/5dea2407
Branch: refs/heads/master
Commit: 5dea2407fda8c3da56a55d2fde76bb3b2d78267d
Parents: 39e3bc8
Author: Alexander Sorokin <al...@akvelon.com>
Authored: Fri Dec 2 13:30:53 2016 +0300
Committer: Alexander Sorokin <al...@akvelon.com>
Committed: Fri Dec 2 13:30:53 2016 +0300
----------------------------------------------------------------------
lib/ParamedicAppUninstall.js | 41 +++++++++++++++++++++------------------
lib/paramedic.js | 11 +++++++----
2 files changed, 29 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/5dea2407/lib/ParamedicAppUninstall.js
----------------------------------------------------------------------
diff --git a/lib/ParamedicAppUninstall.js b/lib/ParamedicAppUninstall.js
index b997d5c..b0954c0 100644
--- a/lib/ParamedicAppUninstall.js
+++ b/lib/ParamedicAppUninstall.js
@@ -22,6 +22,7 @@ var path = require('path');
var fs = require('fs');
var logger = require('./utils').logger;
var util = require('./utils').utilities;
+var Q = require('q');
function ParamedicAppUninstall(appPath, platform) {
this.appPath = appPath;
@@ -30,26 +31,23 @@ function ParamedicAppUninstall(appPath, platform) {
ParamedicAppUninstall.prototype.uninstallApp = function (targetObj, app) {
if (!targetObj || !targetObj.target)
- return;
+ return Q();
switch (this.platform) {
case util.ANDROID:
- this.uninstallAppAndroid(targetObj, app);
- break;
+ return this.uninstallAppAndroid(targetObj, app);
case util.IOS:
- this.uninstallAppIOS(targetObj, app);
- break;
+ return this.uninstallAppIOS(targetObj, app);
case util.WINDOWS:
- this.uninstallAppWindows(targetObj, app);
- break;
+ return this.uninstallAppWindows(targetObj, app);
default:
- break;
+ return Q();
}
};
ParamedicAppUninstall.prototype.uninstallAppAndroid = function (targetObj, app) {
var uninstallCommand = 'adb -s ' + targetObj.target + ' uninstall ' + app;
- this.executeUninstallCommand(uninstallCommand);
+ return this.executeUninstallCommand(uninstallCommand);
};
ParamedicAppUninstall.prototype.uninstallAppWindows = function (targetObj, app) {
@@ -64,24 +62,29 @@ ParamedicAppUninstall.prototype.uninstallAppWindows = function (targetObj, app)
var packageJS = require(packageJSPath);
var appId = packageJS.getAppId(platformPath);
var uninstallCommand = appDeployPath + ' /uninstall ' + appId + ' /targetdevice:' + targetObj.target;
- this.executeUninstallCommand(uninstallCommand);
+ return this.executeUninstallCommand(uninstallCommand);
}
- return;
+ return Q();
};
ParamedicAppUninstall.prototype.uninstallAppIOS = function (targetObj, app) {
var uninstallCommand = 'xcrun simctl uninstall ' + targetObj.simId + ' uninstall ' + app;
- this.executeUninstallCommand(uninstallCommand);
+ return this.executeUninstallCommand(uninstallCommand);
};
ParamedicAppUninstall.prototype.executeUninstallCommand = function (uninstallCommand) {
- logger.info('cordova-paramedic: Running command: ' + uninstallCommand);
- var uninstallResult = shelljs.exec(uninstallCommand, {silent: false, async: false});
- if (uninstallResult.code > 0) {
- logger.error('Failed to uninstall the app');
- logger.error('Error code: ' + uninstallResult.code);
- }
- return;
+ return Q.Promise(function (resolve, reject, notify) {
+ logger.info('cordova-paramedic: Running command: ' + uninstallCommand);
+ shelljs.exec(uninstallCommand, function (code, stdout, stderr) {
+ if (code === 0) {
+ resolve();
+ } else {
+ logger.error('Failed to uninstall the app');
+ logger.error('Error code: ' + code);
+ reject();
+ }
+ }, {silent: false, async: true});
+ }).timeout(60000, 'Uninstall timed out');
};
module.exports = ParamedicAppUninstall;
http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/5dea2407/lib/paramedic.js
----------------------------------------------------------------------
diff --git a/lib/paramedic.js b/lib/paramedic.js
index 51fbc29..9fda944 100644
--- a/lib/paramedic.js
+++ b/lib/paramedic.js
@@ -102,10 +102,13 @@ ParamedicRunner.prototype.run = function () {
// we should NOT do actions below
if (self.config.getAction() !== 'build' && !self.config.shouldUseSauce()) {
self.collectDeviceLogs();
- self.uninstallApp();
- self.killEmulatorProcess();
+ return self.uninstallApp()
+ // do not fail if uninstall fails
+ .fin(function() {
+ self.killEmulatorProcess();
+ self.cleanUpProject();
+ });
}
- self.cleanUpProject();
return self.displaySauceDetails();
});
};
@@ -558,7 +561,7 @@ ParamedicRunner.prototype.collectDeviceLogs = function () {
ParamedicRunner.prototype.uninstallApp = function () {
logger.info('Uninstalling the app.');
var paramedicAppUninstall = new ParamedicAppUninstall(this.tempFolder.name, this.config.getPlatformId());
- paramedicAppUninstall.uninstallApp(this.targetObj,util.PARAMEDIC_DEFAULT_APP_NAME);
+ return paramedicAppUninstall.uninstallApp(this.targetObj,util.PARAMEDIC_DEFAULT_APP_NAME);
};
ParamedicRunner.prototype.getPackageFolder = function () {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org