From bce769de9e4b0a624d7b8af2d7b89c3abf877618 Mon Sep 17 00:00:00 2001 From: islandryu Date: Sat, 18 May 2024 08:08:48 +0900 Subject: [PATCH] fix: move cocoaPods Error --- packages/cli/src/commands/init/init.ts | 41 +++++++++++++++----------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/packages/cli/src/commands/init/init.ts b/packages/cli/src/commands/init/init.ts index 8faa330b6..8d92dd2f9 100644 --- a/packages/cli/src/commands/init/init.ts +++ b/packages/cli/src/commands/init/init.ts @@ -306,26 +306,32 @@ async function createFromTemplate({ if (process.platform === 'darwin') { const installPodsValue = String(installCocoaPods); - if (installPodsValue === 'true') { - didInstallPods = true; - await installPods(loader); - loader.succeed(); - setEmptyHashForCachedDependencies(projectName); - } else if (installPodsValue === 'undefined') { - const {installCocoapods} = await prompt({ - type: 'confirm', - name: 'installCocoapods', - message: `Do you want to install CocoaPods now? ${chalk.reset.dim( - 'Only needed if you run your project in Xcode directly', - )}`, - }); - didInstallPods = installCocoapods; - - if (installCocoapods) { + try { + if (installPodsValue === 'true') { + didInstallPods = true; await installPods(loader); loader.succeed(); setEmptyHashForCachedDependencies(projectName); + } else if (installPodsValue === 'undefined') { + const {installCocoapods} = await prompt({ + type: 'confirm', + name: 'installCocoapods', + message: `Do you want to install CocoaPods now? ${chalk.reset.dim( + 'Only needed if you run your project in Xcode directly', + )}`, + }); + didInstallPods = installCocoapods; + + if (installCocoapods) { + await installPods(loader); + loader.succeed(); + setEmptyHashForCachedDependencies(projectName); + } } + } catch (e) { + throw new CLIError( + 'Installing pods failed. This doesn\'t affect project initialization and you can safely proceed. \nHowever, you will need to install pods manually when running iOS, follow additional steps in "Run instructions for iOS" section.\n', + ); } } } else { @@ -336,8 +342,9 @@ async function createFromTemplate({ if (e instanceof CLIError) { logger.error(e.message); } else if (e instanceof Error) { + const unknownErrorMessage = 'Please report this issue'; logger.error( - 'Installing pods failed. This doesn\'t affect project initialization and you can safely proceed. \nHowever, you will need to install pods manually when running iOS, follow additional steps in "Run instructions for iOS" section.\n', + `An unexpected error occurred: ${e.message}. ${unknownErrorMessage}`, ); } loader.fail();