2016-01-06 01:11:53 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
*
|
|
|
|
* @flow
|
|
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
|
2016-09-06 15:00:00 +00:00
|
|
|
type IOSDeviceInfo = {
|
2016-01-06 01:11:53 +00:00
|
|
|
name: string;
|
|
|
|
udid: string;
|
|
|
|
version: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parses the output of `xcrun simctl list devices` command
|
|
|
|
*/
|
2016-09-06 15:00:00 +00:00
|
|
|
function parseIOSDevicesList(text: string): Array<IOSDeviceInfo> {
|
2016-01-06 01:11:53 +00:00
|
|
|
const devices = [];
|
|
|
|
text.split('\n').forEach((line) => {
|
2016-09-06 15:00:00 +00:00
|
|
|
const device = line.match(/(.*?) \((.*?)\) \[(.*?)\]/);
|
|
|
|
const noSimulator = line.match(/(.*?) \((.*?)\) \[(.*?)\] \((.*?)\)/);
|
|
|
|
if (device != null && noSimulator == null){
|
2016-01-06 01:11:53 +00:00
|
|
|
var name = device[1];
|
2016-09-06 15:00:00 +00:00
|
|
|
var version = device[2];
|
|
|
|
var udid = device[3];
|
|
|
|
devices.push({udid, name, version});
|
2016-01-06 01:11:53 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return devices;
|
|
|
|
}
|
|
|
|
|
2016-09-06 15:00:00 +00:00
|
|
|
module.exports = parseIOSDevicesList;
|