Fix cert exchange on iOS with multiple devices connected

Reviewed By: lblasa, nikoant

Differential Revision: D34142119

fbshipit-source-id: e5edc4962e75f2e6f91d9ed304ffd080fd29ff27
This commit is contained in:
Andrey Goncharov
2022-02-10 05:39:38 -08:00
committed by Facebook GitHub Bot
parent b3cf7e1ad1
commit c33a5f9bef

View File

@@ -17,6 +17,8 @@ import path from 'path';
const tmpDir = promisify(tmp.dir) as (options?: DirOptions) => Promise<string>; const tmpDir = promisify(tmp.dir) as (options?: DirOptions) => Promise<string>;
const logTag = 'iOSCertificateProvider';
// eslint-disable-next-line @typescript-eslint/naming-convention // eslint-disable-next-line @typescript-eslint/naming-convention
export default class iOSCertificateProvider extends CertificateProvider { export default class iOSCertificateProvider extends CertificateProvider {
name = 'iOSCertificateProvider'; name = 'iOSCertificateProvider';
@@ -43,6 +45,7 @@ export default class iOSCertificateProvider extends CertificateProvider {
throw new Error('No iOS devices found'); throw new Error('No iOS devices found');
} }
const deviceMatchList = targets.map(async (target) => { const deviceMatchList = targets.map(async (target) => {
try {
const isMatch = await this.iOSDeviceHasMatchingCSR( const isMatch = await this.iOSDeviceHasMatchingCSR(
appDirectory, appDirectory,
target.udid, target.udid,
@@ -50,6 +53,14 @@ export default class iOSCertificateProvider extends CertificateProvider {
csr, csr,
); );
return {id: target.udid, isMatch}; return {id: target.udid, isMatch};
} catch (e) {
console.info(
`Unable to check for matching CSR in ${target.udid}:${appName}`,
logTag,
e,
);
return {id: target.udid, isMatch: false};
}
}); });
const devices = await Promise.all(deviceMatchList); const devices = await Promise.all(deviceMatchList);
const matchingIds = devices.filter((m) => m.isMatch).map((m) => m.id); const matchingIds = devices.filter((m) => m.isMatch).map((m) => m.id);