Files
flipper/src/fb-stubs/iOSContainerUtility.tsx
Pascal Hartig 3c2d9973e5 Migrate iOSContainerUtility
Summary: TSC actually found a type error here in `safeExec` which is nice.

Reviewed By: danielbuechele

Differential Revision: D16666740

fbshipit-source-id: 28a1ad12190d2351a48323f23c3a69947503625d
2019-08-09 04:02:45 -07:00

65 lines
1.4 KiB
TypeScript

/**
* Copyright 2018-present Facebook.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
* @format
*/
import {promisify} from 'util';
import {DeviceType} from '../devices/BaseDevice';
const exec = promisify(require('child_process').exec);
const errorMessage = 'Physical iOS devices not yet supported';
export type DeviceTarget = {
udid: string;
type: DeviceType;
name: string;
};
function isAvailable(): boolean {
return false;
}
function targets(): Promise<Array<DeviceTarget>> {
return exec('instruments -s devices').then(({stdout}) =>
stdout
.toString()
.split('\n')
.map(line => line.trim())
.map(line => /(.+) \([^(]+\) \[(.*)\]( \(Simulator\))?/.exec(line))
.filter(Boolean)
.filter(
([match, name, udid, isSim]) =>
!isSim && (name.includes('iPhone') || name.includes('iPad')),
)
.map(([match, name, udid]) => {
return {udid: udid, type: 'physical', name: name};
}),
);
}
function push(
udid: string,
src: string,
bundleId: string,
dst: string,
): Promise<void> {
return Promise.reject(errorMessage);
}
function pull(
udid: string,
src: string,
bundleId: string,
dst: string,
): Promise<void> {
return Promise.reject(errorMessage);
}
export default {
isAvailable: isAvailable,
targets: targets,
push: push,
pull: pull,
};