Skip to content

Commit 46bea78

Browse files
Fix detection of iPad Pro
When the device name contains `()`, the regex matches it instead of the GUID and after that we exclude the device from the list with available devices. Such devices are: ``` iPad Pro (9.7 inch) (7FF984D4-0755-432D-BE0E-6EB44F0489CB) (Shutdown) iPad Pro (12.9 inch) (F02012C8-6D4D-46FF-90D7-5DF90EF579E8) (Booted) ``` This way users are unable to execute any operation on such simulators. Fix the regular expression to match based on the GUID instead of using the `(` as main part of the regex. Check this gist for comparison of the results with the old and the new regex: https://gist.github.com/rosen-vladimirov/85b4ccb78af2e604ac91efecd2a67150
1 parent 0a21a08 commit 46bea78

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/simctl.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,14 @@ export class Simctl implements ISimctl {
9797
for (let line of match[0].split('\n').slice(1)) {
9898
// a line is something like
9999
// iPhone 4s (A99FFFC3-8E19-4DCF-B585-7D9D46B4C16E) (Shutdown)
100+
// iPad Air 2 (9696A8ED-3020-49FC-90D6-DAFD29A0EA8D) (Shutdown)
101+
// iPad Pro (9.7 inch) (7FF984D4-0755-432D-BE0E-6EB44F0489CB) (Shutdown)
102+
// iPad Pro (12.9 inch) (F02012C8-6D4D-46FF-90D7-5DF90EF579E8) (Booted)
100103
// retrieve:
101104
// iPhone 4s
102105
// A99FFFC3-8E19-4DCF-B585-7D9D46B4C16E
103106
// Shutdown
104-
let lineRegex = /^ ([^\(]+) \(([^\)]+)\) \(([^\)]+)\)( \(([^\)]+)\))*/;
107+
let lineRegex = /^\s+(.*?)\s+\(([0-9A-F]{8}(?:-[0-9A-F]{4}){3}-[0-9A-F]{12})\)\s+\((.*?)\)(\s+\((?:.*?)\))?/;
105108
let lineMatch = lineRegex.exec(line);
106109
if (lineMatch === null) {
107110
errors.fail('Could not match line. ' + line);

0 commit comments

Comments
 (0)