Repository: cordova-wp8
Updated Branches:
  refs/heads/master 175692cd4 -> b2b1e6185


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/d1d535fa
Tree: http://git-wip-us.apache.org/repos/asf/cordova-wp8/tree/d1d535fa
Diff: http://git-wip-us.apache.org/repos/asf/cordova-wp8/diff/d1d535fa

Branch: refs/heads/master
Commit: d1d535fad62e1d8ce76f3e575c69d33ee912e180
Parents: 2e90a47
Author: sgrebnov <[email protected]>
Authored: Wed Sep 24 20:55:13 2014 +0400
Committer: sgrebnov <[email protected]>
Committed: Wed Sep 24 20:55:13 2014 +0400

----------------------------------------------------------------------
 template/cordova/lib/device.js | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/d1d535fa/template/cordova/lib/device.js
----------------------------------------------------------------------
diff --git a/template/cordova/lib/device.js b/template/cordova/lib/device.js
index c963533..64ee00f 100644
--- a/template/cordova/lib/device.js
+++ b/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');


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to