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 2014/09/29 10:13:59 UTC
[2/2] git commit: CB-7616 partial match support for --target
CB-7616 partial match support for --target
Project: http://git-wip-us.apache.org/repos/asf/cordova-wp8/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-wp8/commit/1e363e17
Tree: http://git-wip-us.apache.org/repos/asf/cordova-wp8/tree/1e363e17
Diff: http://git-wip-us.apache.org/repos/asf/cordova-wp8/diff/1e363e17
Branch: refs/heads/3.6.x
Commit: 1e363e17af912160bf25e62e70ef12a0a1a81c28
Parents: 5578551
Author: sgrebnov <v-...@microsoft.com>
Authored: Mon Sep 29 12:05:27 2014 +0400
Committer: sgrebnov <v-...@microsoft.com>
Committed: Mon Sep 29 12:05:27 2014 +0400
----------------------------------------------------------------------
wp8/template/cordova/lib/device.js | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/1e363e17/wp8/template/cordova/lib/device.js
----------------------------------------------------------------------
diff --git a/wp8/template/cordova/lib/device.js b/wp8/template/cordova/lib/device.js
index c963533..64ee00f 100644
--- a/wp8/template/cordova/lib/device.js
+++ b/wp8/template/cordova/lib/device.js
@@ -27,11 +27,14 @@ var Q = require('q'),
// return rejected promise if device with name specified not found
module.exports.findDevice = function (target) {
target = target.toLowerCase();
- return module.exports.listDevices()
- .then(function(deviceList) {
- for (var idx in deviceList){
- if (deviceList[idx].toLowerCase() == target) {
- return Q.resolve(idx);
+ return module.exports.listDevices().then(function(deviceList) {
+ // CB-7616 since we use partial match shorter names should go first,
+ // example case is ['Emulator WVGA 512MB', 'Emulator WVGA']
+ var sortedList = deviceList.concat().sort(function (l, r) { return l.length > r.length; });
+ for (var idx in sortedList) {
+ if (sortedList[idx].toLowerCase().indexOf(target) > -1) {
+ // we should return index based on original list
+ return Q.resolve(deviceList.indexOf(sortedList[idx]));
}
}
return Q.reject('Specified device not found');