From 393e47641bfd0987f79a97bb00628deeb46f7980 Mon Sep 17 00:00:00 2001 From: Pascal Hartig Date: Wed, 18 Aug 2021 15:47:32 -0700 Subject: [PATCH] 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 --- .../src/server/utils/CertificateProvider.tsx | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/desktop/app/src/server/utils/CertificateProvider.tsx b/desktop/app/src/server/utils/CertificateProvider.tsx index 9e3755c43..fb48d708f 100644 --- a/desktop/app/src/server/utils/CertificateProvider.tsx +++ b/desktop/app/src/server/utils/CertificateProvider.tsx @@ -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}: ` +