Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
Merge branch 'CB-7616' of https://github.com/MSOpenTech/cordova-wp8
  • Loading branch information
purplecabbage committed Oct 7, 2014
2 parents 175692c + d1d535f commit b2b1e6185444e0dd6a6b9b19df9005cfc5bc5d80
Showing 1 changed file with 8 additions and 5 deletions.
@@ -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');

0 comments on commit b2b1e61

Please sign in to comment.