UNPKG

1.52 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = void 0;
7/**
8 * Copyright (c) Facebook, Inc. and its affiliates.
9 *
10 * This source code is licensed under the MIT license found in the
11 * LICENSE file in the root directory of this source tree.
12 *
13 */
14
15/**
16 * Parses the output of the `xcrun instruments -s` command and returns metadata
17 * about available iOS simulators and physical devices, as well as host Mac for
18 * Catalyst purposes.
19 *
20 * Expected text looks roughly like this:
21 *
22 * ```
23 * == Devices ==
24 * this-mac-device [UDID]
25 * A Physical Device (OS Version) (UDID)
26 *
27 * == Simulators ==
28 * A Simulator Device (OS Version) (UDID)
29 * ```
30 */
31function parseIOSDevicesList(text) {
32 const devices = [];
33 let isSimulator = false;
34 if (text.indexOf('== Simulators ==') === -1) {
35 return [];
36 }
37 text.split('\n').forEach(line => {
38 if (line === '== Simulators ==') {
39 isSimulator = true;
40 }
41 const device = line.match(/(.*?) (\(([0-9.]+)\) )?\(([0-9A-F-]+)\)/i);
42 if (device) {
43 const [, name,, version, udid] = device;
44 const metadata = {
45 name,
46 udid
47 };
48 if (version) {
49 metadata.version = version;
50 metadata.type = isSimulator ? 'simulator' : 'device';
51 } else {
52 metadata.type = 'catalyst';
53 }
54 devices.push(metadata);
55 }
56 });
57 return devices;
58}
59var _default = parseIOSDevicesList;
60exports.default = _default;
61
62//# sourceMappingURL=parseXctraceIOSDevicesList.js.map
\No newline at end of file