Skip to content

Commit 3abdf48

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 c78aa88 commit 3abdf48

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
@@ -87,11 +87,14 @@ export class Simctl implements ISimctl {
8787
for (let line of match[0].split('\n').slice(1)) {
8888
// a line is something like
8989
// iPhone 4s (A99FFFC3-8E19-4DCF-B585-7D9D46B4C16E) (Shutdown)
90+
// iPad Air 2 (9696A8ED-3020-49FC-90D6-DAFD29A0EA8D) (Shutdown)
91+
// iPad Pro (9.7 inch) (7FF984D4-0755-432D-BE0E-6EB44F0489CB) (Shutdown)
92+
// iPad Pro (12.9 inch) (F02012C8-6D4D-46FF-90D7-5DF90EF579E8) (Booted)
9093
// retrieve:
9194
// iPhone 4s
9295
// A99FFFC3-8E19-4DCF-B585-7D9D46B4C16E
9396
// Shutdown
94-
let lineRegex = /^ ([^\(]+) \(([^\)]+)\) \(([^\)]+)\)( \(([^\)]+)\))*/;
97+
let lineRegex = /^\s+(.*?)\s+\(([0-9A-F]{8}(?:-[0-9A-F]{4}){3}-[0-9A-F]{12})\)\s+\((.*?)\)(\s+\((?:.*?)\))?/;
9598
let lineMatch = lineRegex.exec(line);
9699
if (lineMatch === null) {
97100
errors.fail('Could not match line. ' + line);

0 commit comments

Comments
 (0)