You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sg...@apache.org on 2015/05/27 15:09:31 UTC
cordova-windows git commit: CB-9074 Fixed incorrect parameter error
when installing to emulator
Repository: cordova-windows
Updated Branches:
refs/heads/master f2100233a -> 56adf7d5a
CB-9074 Fixed incorrect parameter error when installing to emulator
github close #86
Project: http://git-wip-us.apache.org/repos/asf/cordova-windows/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-windows/commit/56adf7d5
Tree: http://git-wip-us.apache.org/repos/asf/cordova-windows/tree/56adf7d5
Diff: http://git-wip-us.apache.org/repos/asf/cordova-windows/diff/56adf7d5
Branch: refs/heads/master
Commit: 56adf7d5acb369a6df95d0976f35146b905dfde6
Parents: f210023
Author: alsorokin <al...@akvelon.com>
Authored: Wed May 27 14:45:39 2015 +0300
Committer: sgrebnov <v-...@microsoft.com>
Committed: Wed May 27 16:08:40 2015 +0300
----------------------------------------------------------------------
spec/unit/run.spec.js | 2 +-
template/cordova/lib/package.js | 48 +++++++++++++++---------------------
template/cordova/lib/run.js | 6 ++---
3 files changed, 24 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/56adf7d5/spec/unit/run.spec.js
----------------------------------------------------------------------
diff --git a/spec/unit/run.spec.js b/spec/unit/run.spec.js
index 3a28861..94978a3 100644
--- a/spec/unit/run.spec.js
+++ b/spec/unit/run.spec.js
@@ -140,7 +140,7 @@ describe('run method', function() {
file: 'testfile'
});
});
- run.__set__('packages.deployToPhoneAndRun', function() {
+ run.__set__('packages.deployToPhone', function() {
deployToPhone();
return Q();
});
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/56adf7d5/template/cordova/lib/package.js
----------------------------------------------------------------------
diff --git a/template/cordova/lib/package.js b/template/cordova/lib/package.js
index 5998dff..723b68b 100644
--- a/template/cordova/lib/package.js
+++ b/template/cordova/lib/package.js
@@ -143,39 +143,31 @@ module.exports.listDevices = function () {
});
};
-// deploys specified phone package to device/emulator
-module.exports.deployToPhone = function (package, deployTarget, targetWindows10) {
- var getTarget = deployTarget == 'device' ? Q('de') :
- deployTarget == 'emulator' ? Q('xd') : module.exports.findDevice(deployTarget);
-
- // /installlaunch option sometimes fails with 'Error: The parameter is incorrect.'
- // so we use separate steps to /install and then /launch
- return getTarget.then(function(target) {
- return utils.getAppDeployUtils(targetWindows10).then(function(appDeployUtils) {
- console.log('Installing application');
- return spawn(appDeployUtils, ['/install', package.appx, '/targetdevice:' + target]).then(function() {
- // TODO: resolve AppId without specifying project root;
- return module.exports.getAppId(path.join(__dirname, '..', '..'));
- }).then(function(appId) {
- console.log('Running application');
- return spawn(appDeployUtils, ['/launch', appId, '/targetdevice:' + target]);
- });
- });
- });
-};
function installAppToPhone(appDeployUtils, package, target, update) {
- var cmd = update ? '/updatelaunch' : '/installlaunch';
+ // /installlaunch option sometimes fails with 'Error: The parameter is incorrect.'
+ // so we use separate steps to /install or /update and then /launch
+ var cmd = update ? '/update' : '/install';
console.log('Installing application...');
return spawn(appDeployUtils, [cmd, package.appx, '/targetdevice:' + target]);
}
+function runAppOnPhone(appDeployUtils, target) {
+ return Q().then(function() {
+ return module.exports.getAppId(path.join(__dirname, '..', '..'));
+ }).then(function(appId) {
+ console.log('Running application... ');
+ return spawn(appDeployUtils, ['/launch', appId, '/targetdevice:' + target]);
+ });
+}
+
function uninstallAppFromPhone(appDeployUtils, package, target) {
console.log('Attempting to remove previously installed application...');
return spawn(appDeployUtils, ['/uninstall', package.phoneId, '/targetdevice:' + target]);
}
-module.exports.deployToPhoneAndRun = function (package, deployTarget, targetWindows10) {
+// deploys specified phone package to device/emulator and launches it
+module.exports.deployToPhone = function (package, deployTarget, targetWindows10) {
var getTarget = deployTarget == 'device' ? Q('de') :
deployTarget == 'emulator' ? Q('xd') : module.exports.findDevice(deployTarget);
@@ -185,20 +177,20 @@ module.exports.deployToPhoneAndRun = function (package, deployTarget, targetWind
return uninstallAppFromPhone(appDeployUtils, package, target).then(
function() {}, function() {}).then(function() {
return installAppToPhone(appDeployUtils, package, target, false);
- }).then(function() {}, function(error) {
-
+ }).then(function() {
+ return runAppOnPhone(appDeployUtils, target);
+ }, function(error) {
if (error.indexOf('Error code 2148734208 for command') === 0) {
return installAppToPhone(appDeployUtils, package, target, true);
- }
- else {
+ } else if (error.indexOf('Error code -2146233088') === 0) {
+ throw new Error('No Windows Phone device was detected.');
+ } else {
console.warn('Unexpected error from installation:');
console.warn(error);
console.warn('You may have previously installed the app with an earlier version of cordova-windows.');
console.warn('Ensure the app is uninstalled from the phone and then try to run again.');
throw error;
}
- }).then(function() {
- return module.exports.getAppId(path.join(__dirname, '..', '..'));
});
});
});
http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/56adf7d5/template/cordova/lib/run.js
----------------------------------------------------------------------
diff --git a/template/cordova/lib/run.js b/template/cordova/lib/run.js
index c704b58..36ddf0c 100644
--- a/template/cordova/lib/run.js
+++ b/template/cordova/lib/run.js
@@ -105,13 +105,13 @@ module.exports.run = function (argv) {
console.log('\nDeploying ' + pkg.type + ' package to ' + deployTarget + ':\n' + pkg.appx);
switch (pkg.type) {
case 'phone':
- return packages.deployToPhoneAndRun(pkg, deployTarget, false).catch(function(e) {
+ return packages.deployToPhone(pkg, deployTarget, false).catch(function(e) {
if (args.target || args.emulator || args.device) {
throw e; // Explicit target, carry on
}
// 'device' was inferred initially, because no target was specified
- return packages.deployToPhoneAndRun(pkg, 'emulator', false);
+ return packages.deployToPhone(pkg, 'emulator', false);
});
case 'windows10':
@@ -120,7 +120,7 @@ module.exports.run = function (argv) {
if (args.emulator || args.target === 'emulator') {
console.warn('Windows 10 Phone emulator is not currently supported, attempting deploy to device.');
}
- return packages.deployToPhoneAndRun(pkg, 'device', true);
+ return packages.deployToPhone(pkg, 'device', true);
}
else {
return packages.deployToDesktop(pkg, deployTarget, projectType);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org