Skip to content

Commit

Permalink
feat: automatically install pods in legacy init (#386)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Bento authored and thymikee committed May 15, 2019
1 parent 6fb96af commit 875a025
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
8 changes: 8 additions & 0 deletions packages/cli/src/commands/init/initCompat.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import printRunInstructions from './printRunInstructions';
import {createProjectFromTemplate} from '../../tools/generator/templates';
import * as PackageManager from '../../tools/packageManager';
import {logger} from '@react-native-community/cli-tools';
import installPods from '../../tools/installPods';

/**
* Creates the template for a React Native project given the provided
Expand Down Expand Up @@ -76,6 +77,13 @@ async function generateProject(destinationRoot, newProjectName, options) {
]);

addJestToPackageJson(destinationRoot);

if (process.platform === 'darwin') {
logger.info('Installing required CocoaPods dependencies');

await installPods({projectName: newProjectName});
}

printRunInstructions(destinationRoot, newProjectName);
}

Expand Down
10 changes: 7 additions & 3 deletions packages/cli/src/tools/installPods.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ async function installPods({
loader,
}: {
projectName: string,
loader: typeof Ora,
loader?: typeof Ora,
}) {
try {
process.chdir('ios');
Expand All @@ -26,7 +26,9 @@ async function installPods({
try {
await commandExists('pod');
} catch (e) {
loader.stop();
if (loader) {
loader.stop();
}

const {shouldInstallCocoaPods} = await inquirer.prompt([
{
Expand Down Expand Up @@ -61,7 +63,9 @@ async function installPods({

// This only shows when `CocoaPods` is automatically installed,
// if it's already installed then we just show the `Installing dependencies` step
loader.start('Installing CocoaPods dependencies');
if (loader) {
loader.start('Installing CocoaPods dependencies');
}
}
}

Expand Down

0 comments on commit 875a025

Please sign in to comment.