Skip to content

Commit

Permalink
fix: move cocoaPods Error
Browse files Browse the repository at this point in the history
  • Loading branch information
islandryu committed May 17, 2024
1 parent 63ebe86 commit bce769d
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions packages/cli/src/commands/init/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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();
Expand Down

0 comments on commit bce769d

Please sign in to comment.