Skip to content

Commit

Permalink
Fixes #202 - ib.js/getdevicetypes gets wrong list of devices versus s…
Browse files Browse the repository at this point in the history
…howdevicetypes
  • Loading branch information
shazron committed Nov 9, 2016
1 parent 4ba9e43 commit 487830b
Showing 1 changed file with 11 additions and 31 deletions.
42 changes: 11 additions & 31 deletions src/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,36 +263,6 @@ var lib = {
var druntimes = findRuntimesGroupByDeviceProperty(list, 'name', true);
var name_id_map = {};

list.devicetypes.forEach(function(device) {
name_id_map[ device.name ] = device.id;
});

list = [];
var remove = function(runtime) {
// remove "iOS" prefix in runtime, remove prefix "com.apple.CoreSimulator.SimDeviceType." in id
list.push(util.format('%s, %s', name_id_map[ deviceName ].replace(/^com.apple.CoreSimulator.SimDeviceType./, ''), runtime.replace(/^iOS /, '')));
};

for (var deviceName in druntimes) {
var runtimes = druntimes[ deviceName ];

if (!(deviceName in name_id_map)) {
continue;
}
runtimes.forEach(remove);
}
return list;
},
//jscs:enable disallowUnusedParams

//jscs:disable disallowUnusedParams
showdevicetypes: function(args) {
var options = { silent: true };
var list = simctl.list(options).json;

var druntimes = findRuntimesGroupByDeviceProperty(list, 'name', true);
var name_id_map = {};

list.devicetypes.forEach(function(device) {
// replace hyphens in iPad Pro name which differ in 'Device Types' and 'Devices'
if (device.name.indexOf('iPad Pro') === 0) {
Expand All @@ -301,9 +271,10 @@ var lib = {
name_id_map[ device.name ] = device.id;
});

list = [];
var remove = function(runtime) {
// remove "iOS" prefix in runtime, remove prefix "com.apple.CoreSimulator.SimDeviceType." in id
console.log(util.format('%s, %s', name_id_map[ deviceName ].replace(/^com.apple.CoreSimulator.SimDeviceType./, ''), runtime.replace(/^iOS /, '')));
list.push(util.format('%s, %s', name_id_map[ deviceName ].replace(/^com.apple.CoreSimulator.SimDeviceType./, ''), runtime.replace(/^iOS /, '')));
};

for (var deviceName in druntimes) {
Expand All @@ -319,6 +290,15 @@ var lib = {
}
runtimes.forEach(remove);
}
return list;
},
//jscs:enable disallowUnusedParams

//jscs:disable disallowUnusedParams
showdevicetypes: function(args) {
this.getdevicetypes().forEach(function(device){
console.log(device);
});
},
//jscs:enable disallowUnusedParams

Expand Down

0 comments on commit 487830b

Please sign in to comment.