Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Correctly display errors in react-native init #2394

Merged
merged 5 commits into from
Sep 9, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 29 additions & 22 deletions packages/cli/src/commands/init/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,41 +310,48 @@ 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) {
logger.error(
'Installing Cocoapods failed. This doesn\'t affect project initialization and you can safely proceed. \nHowever, you will need to install Cocoapods manually when running iOS, follow additional steps in "Run instructions for iOS" section.\n',
);
szymonrybczak marked this conversation as resolved.
Show resolved Hide resolved
}
}
} else {
didInstallPods = false;
loader.succeed('Dependencies installation skipped');
}
} catch (e) {
loader.fail();
if (e instanceof Error) {
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',
);
logger.debug(e as any);
logger.log('\n');
if (e instanceof CLIError) {
logger.error(e.message);
} else if (e instanceof Error) {
logger.error(`An unexpected error occurred: ${e.message}.`);
}
didInstallPods = false;
logger.debug(e as any);
process.exit(1);
szymonrybczak marked this conversation as resolved.
Show resolved Hide resolved
} finally {
fs.removeSync(templateSourceDir);
}
Expand Down
Loading