Skip to content

Commit 1ee45d0

Browse files
committed
Fixes #203 - Running "ios-sim showdevicetypes" throws error "Cannot read property 'replace' of undefined"
1 parent 015a7f1 commit 1ee45d0

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/lib.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,15 @@ var lib = {
277277
});
278278

279279
list = [];
280-
var remove = function(runtime) {
280+
var remove = function(devicename, runtime) {
281281
// remove "iOS" prefix in runtime, remove prefix "com.apple.CoreSimulator.SimDeviceType." in id
282-
list.push(util.format('%s, %s', name_id_map[ deviceName ].replace(/^com.apple.CoreSimulator.SimDeviceType./, ''), runtime.replace(/^iOS /, '')));
282+
list.push(util.format('%s, %s', name_id_map[ devicename ].replace(/^com.apple.CoreSimulator.SimDeviceType./, ''), runtime.replace(/^iOS /, '')));
283+
};
284+
285+
var cur = function(devicename) {
286+
return function(runtime) {
287+
remove(devicename, runtime);
288+
};
283289
};
284290

285291
for (var deviceName in druntimes) {
@@ -289,7 +295,8 @@ var lib = {
289295
if (!(dname in name_id_map)) {
290296
continue;
291297
}
292-
runtimes.forEach(remove);
298+
299+
runtimes.forEach(cur(dname));
293300
}
294301
return list;
295302
},

0 commit comments

Comments
 (0)