Skip to content

Commit

Permalink
Fixes #203 - Running "ios-sim showdevicetypes" throws error "Cannot r…
Browse files Browse the repository at this point in the history
…ead property 'replace' of undefined"
  • Loading branch information
shazron committed Dec 9, 2016
1 parent 015a7f1 commit 1ee45d0
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/lib.js
Expand Up @@ -277,9 +277,15 @@ var lib = {
});

list = [];
var remove = function(runtime) {
var remove = function(devicename, 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 /, '')));
list.push(util.format('%s, %s', name_id_map[ devicename ].replace(/^com.apple.CoreSimulator.SimDeviceType./, ''), runtime.replace(/^iOS /, '')));
};

var cur = function(devicename) {
return function(runtime) {
remove(devicename, runtime);
};
};

for (var deviceName in druntimes) {
Expand All @@ -289,7 +295,8 @@ var lib = {
if (!(dname in name_id_map)) {
continue;
}
runtimes.forEach(remove);

runtimes.forEach(cur(dname));
}
return list;
},
Expand Down

0 comments on commit 1ee45d0

Please sign in to comment.