Skip to content

Commit 487830b

Browse files
committed
Fixes #202 - ib.js/getdevicetypes gets wrong list of devices versus showdevicetypes
1 parent 4ba9e43 commit 487830b

File tree

1 file changed

+11
-31
lines changed

1 file changed

+11
-31
lines changed

src/lib.js

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -263,36 +263,6 @@ var lib = {
263263
var druntimes = findRuntimesGroupByDeviceProperty(list, 'name', true);
264264
var name_id_map = {};
265265

266-
list.devicetypes.forEach(function(device) {
267-
name_id_map[ device.name ] = device.id;
268-
});
269-
270-
list = [];
271-
var remove = function(runtime) {
272-
// remove "iOS" prefix in runtime, remove prefix "com.apple.CoreSimulator.SimDeviceType." in id
273-
list.push(util.format('%s, %s', name_id_map[ deviceName ].replace(/^com.apple.CoreSimulator.SimDeviceType./, ''), runtime.replace(/^iOS /, '')));
274-
};
275-
276-
for (var deviceName in druntimes) {
277-
var runtimes = druntimes[ deviceName ];
278-
279-
if (!(deviceName in name_id_map)) {
280-
continue;
281-
}
282-
runtimes.forEach(remove);
283-
}
284-
return list;
285-
},
286-
//jscs:enable disallowUnusedParams
287-
288-
//jscs:disable disallowUnusedParams
289-
showdevicetypes: function(args) {
290-
var options = { silent: true };
291-
var list = simctl.list(options).json;
292-
293-
var druntimes = findRuntimesGroupByDeviceProperty(list, 'name', true);
294-
var name_id_map = {};
295-
296266
list.devicetypes.forEach(function(device) {
297267
// replace hyphens in iPad Pro name which differ in 'Device Types' and 'Devices'
298268
if (device.name.indexOf('iPad Pro') === 0) {
@@ -301,9 +271,10 @@ var lib = {
301271
name_id_map[ device.name ] = device.id;
302272
});
303273

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

309280
for (var deviceName in druntimes) {
@@ -319,6 +290,15 @@ var lib = {
319290
}
320291
runtimes.forEach(remove);
321292
}
293+
return list;
294+
},
295+
//jscs:enable disallowUnusedParams
296+
297+
//jscs:disable disallowUnusedParams
298+
showdevicetypes: function(args) {
299+
this.getdevicetypes().forEach(function(device){
300+
console.log(device);
301+
});
322302
},
323303
//jscs:enable disallowUnusedParams
324304

0 commit comments

Comments
 (0)