From d6fb6e5ec346bc3852268c6f79c2fbca1f2c4073 Mon Sep 17 00:00:00 2001 From: Lucas Bento Date: Wed, 15 May 2019 15:47:49 +0200 Subject: [PATCH 1/2] Add message that shows only if `cocoapods` installation take more than 30 seconds --- packages/cli/src/tools/installPods.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/cli/src/tools/installPods.js b/packages/cli/src/tools/installPods.js index a0b4dc2fc..14b49e070 100644 --- a/packages/cli/src/tools/installPods.js +++ b/packages/cli/src/tools/installPods.js @@ -40,14 +40,24 @@ async function installPods({ }, ]); + // This is only shown if it takes more than 30 seconds for the CocoaPods installation to finish + const cocoaPodsInstallationTimeMessage = setTimeout( + () => logger.info('Installing CocoaPods, this may take a few minutes'), + 30000, + ); + if (shouldInstallCocoaPods) { try { // First attempt to install `cocoapods` await execa('gem', ['install', 'cocoapods']); + + clearTimeout(cocoaPodsInstallationTimeMessage); } catch (_error) { try { // If that doesn't work then try with sudo await execa('sudo', ['gem', 'install', 'cocoapods']); + + clearTimeout(cocoaPodsInstallationTimeMessage); } catch (error) { logger.log(error.stderr); From 9ff193d970dd55a9c5c35d3276c8f5ab24250cf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Wed, 15 May 2019 17:00:24 +0200 Subject: [PATCH 2/2] adjustments --- packages/cli/src/tools/installPods.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/cli/src/tools/installPods.js b/packages/cli/src/tools/installPods.js index 14b49e070..4af7acb3b 100644 --- a/packages/cli/src/tools/installPods.js +++ b/packages/cli/src/tools/installPods.js @@ -7,6 +7,8 @@ import inquirer from 'inquirer'; import commandExists from 'command-exists'; import {logger} from '@react-native-community/cli-tools'; +const COCOAPODS_INSTALLATION_TIMEOUT = 30000; + async function installPods({ projectName, loader, @@ -40,24 +42,20 @@ async function installPods({ }, ]); - // This is only shown if it takes more than 30 seconds for the CocoaPods installation to finish - const cocoaPodsInstallationTimeMessage = setTimeout( - () => logger.info('Installing CocoaPods, this may take a few minutes'), - 30000, - ); - if (shouldInstallCocoaPods) { + // Show a helpful notice when installation takes more than usually + const cocoaPodsInstallationTimeMessage = setTimeout( + () => + logger.info('Installing CocoaPods, this may take a few minutes'), + COCOAPODS_INSTALLATION_TIMEOUT, + ); try { // First attempt to install `cocoapods` await execa('gem', ['install', 'cocoapods']); - - clearTimeout(cocoaPodsInstallationTimeMessage); } catch (_error) { try { // If that doesn't work then try with sudo await execa('sudo', ['gem', 'install', 'cocoapods']); - - clearTimeout(cocoaPodsInstallationTimeMessage); } catch (error) { logger.log(error.stderr); @@ -67,6 +65,8 @@ async function installPods({ )}`, ); } + } finally { + clearTimeout(cocoaPodsInstallationTimeMessage); } // This only shows when `CocoaPods` is automatically installed,