From 876bfe263bb189f010100884681c1a9eb11c3d2e Mon Sep 17 00:00:00 2001 From: Lucas Bento Date: Thu, 9 May 2019 13:10:29 +0200 Subject: [PATCH] Check which extension for the project to print out on the run instructions for iOS --- packages/cli/src/commands/init/init.js | 4 +++- .../src/commands/init/printRunInstructions.js | 17 ++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/cli/src/commands/init/init.js b/packages/cli/src/commands/init/init.js index 664c3c66d6..ba4dbaea94 100644 --- a/packages/cli/src/commands/init/init.js +++ b/packages/cli/src/commands/init/init.js @@ -272,7 +272,9 @@ export default (async function initialize( try { await createProject(projectName, options, version); - printRunInstructions(process.cwd(), projectName); + await execa('rm', ['-rf', 'ios/Lol.xcworkspace']); + + await printRunInstructions(process.cwd(), projectName); } catch (e) { logger.error(e.message); fs.removeSync(projectName); diff --git a/packages/cli/src/commands/init/printRunInstructions.js b/packages/cli/src/commands/init/printRunInstructions.js index 8a9205fe64..e958b6229e 100644 --- a/packages/cli/src/commands/init/printRunInstructions.js +++ b/packages/cli/src/commands/init/printRunInstructions.js @@ -9,19 +9,22 @@ */ import path from 'path'; +import fs from 'fs-extra'; import chalk from 'chalk'; import {logger} from '@react-native-community/cli-tools'; -function printRunInstructions(projectDir: string, projectName: string) { +async function printRunInstructions(projectDir: string, projectName: string) { const absoluteProjectDir = path.resolve(projectDir); - const xcodeProjectPath = `${path.resolve( - projectDir, - 'ios', - projectName, - )}.xcworkspace`; + const iosProjectDir = path.resolve(projectDir, 'ios'); + + const iosPodsFile = path.resolve(iosProjectDir, `${projectName}.xcworkspace`); + const isUsingPods = await fs.pathExists(iosPodsFile); + const relativeXcodeProjectPath = path.relative( process.cwd(), - xcodeProjectPath, + isUsingPods + ? iosPodsFile + : path.resolve(iosProjectDir, `${projectName}.xcodeproj`), ); logger.log(`