cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nikhilkh <...@git.apache.org>
Subject [GitHub] cordova-windows pull request: CB-9283: Add support for Windows 10 ...
Date Mon, 13 Jul 2015 23:57:15 GMT
Github user nikhilkh commented on a diff in the pull request:

    https://github.com/apache/cordova-windows/pull/96#discussion_r34525670
  
    --- Diff: template/cordova/lib/package.js ---
    @@ -130,58 +145,47 @@ module.exports.findDevice = function (target) {
     };
     
     // returns array of available devices names
    -module.exports.listDevices = function () {
    -    return utils.getAppDeployUtils().then(function(appDeployUtils) {
    -        return exec('"' + appDeployUtils + '" /enumeratedevices').then(function(output)
{
    -            return Q.resolve(output.split('\n').map(function(line) {
    -                var match = /\s*(\d)+\s+(.*)/.exec(line);
    -                return match && match[2];
    -            }).filter(function (line) {
    -                return line;
    -            }));
    +module.exports.listDevices = function (deploymentTool) {
    +    
    +    return deploymentTool.enumerateDevices().then(function(deviceList) {
    +        return deviceList.map(function(device) {
    +            return device.toString();
             });
    -    });
    -};
    -
     
    -function installAppToPhone(appDeployUtils, package, target, update) {
    -    // /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(e) {
    +        console.warn('Failed to enumerate devices');
    +        console.warn(e);
     
    -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]);
    +        throw e;
         });
    -}
    +};
    +
     
     function uninstallAppFromPhone(appDeployUtils, package, target) {
         console.log('Attempting to remove previously installed application...');
    -    return spawn(appDeployUtils, ['/uninstall', package.phoneId, '/targetdevice:' + target]);
    +    return appDeployUtils.uninstallAppPackage(package.phoneId, target);
     }
     
     // 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);
    -
    -    return getTarget.then(function(target) {
    -        return utils.getAppDeployUtils(targetWindows10).then(function(appDeployUtils)
{
    +module.exports.deployToPhone = function (package, deployTarget, targetWindows10, deploymentTool)
{
    +    var deployment;
    +    if (deploymentTool) {
    +        deployment = Q(deploymentTool);
    +    }
    +    else {
    +        deployment = utils.getAppDeployUtils(targetWindows10);
    +    }
     
    -            return uninstallAppFromPhone(appDeployUtils, package, target).then(
    +    return deployment.then(function(deploymentTool) {
    +        return module.exports.findDevice(deploymentTool, deployTarget).then(function(target)
{
    +            return uninstallAppFromPhone(deploymentTool, package, target).then(
                     function() {}, function() {}).then(function() {
    -                    return installAppToPhone(appDeployUtils, package, target, false);
    -                }).then(function() {
    -                    return runAppOnPhone(appDeployUtils, target);
    -                }, function(error) {
    +                    // shouldUpdate = false because we've already uninstalled
    +                    return deploymentTool.installAppPackage(package.appx, target, true,
false);
    --- End diff --
    
    Thanks! :clap: 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


Mime
View raw message