Asyncify complex promise function

Summary:
Linter flagged this as it's using promises inside
promises. This is a bit easier to read.

Reviewed By: timur-valiev

Differential Revision: D30402783

fbshipit-source-id: aee7dedc4468538bceec4fc64379f8b2d89a660c
This commit is contained in:
Pascal Hartig
2021-08-18 15:47:32 -07:00
committed by Facebook GitHub Bot
parent 45ce538c8d
commit 393e47641b

View File

@@ -309,26 +309,24 @@ export default class CertificateProvider {
}
if (os === 'iOS' || os === 'windows' || os == 'MacOS') {
return promisify(fs.writeFile)(destination + filename, contents).catch(
(err) => {
async (err) => {
if (os === 'iOS') {
// Writing directly to FS failed. It's probably a physical device.
const relativePathInsideApp =
this.getRelativePathInAppContainer(destination);
return appNamePromise
.then((appName) => {
return this.getTargetiOSDeviceId(appName, destination, csr);
})
.then((udid) => {
return appNamePromise.then((appName) =>
this.pushFileToiOSDevice(
udid,
appName,
relativePathInsideApp,
filename,
contents,
),
);
});
const appName = await appNamePromise;
const udid = await this.getTargetiOSDeviceId(
appName,
destination,
csr,
);
return await this.pushFileToiOSDevice(
udid,
appName,
relativePathInsideApp,
filename,
contents,
);
}
throw new Error(
`Invalid appDirectory recieved from ${os} device: ${destination}: ` +