Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Commit

Permalink
Add support for react-native projects (#1813)
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanBacon committed Apr 5, 2020
1 parent 7fab875 commit 4c41e0a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 7 additions & 5 deletions packages/package-manager/src/CocoaPodsPackageManager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import spawnAsync, { SpawnOptions, SpawnResult } from '@expo/spawn-async';
import chalk from 'chalk';
import findWorkspaceRoot from 'find-yarn-workspace-root';
import fs from 'fs-extra';
import path from 'path';

Expand All @@ -11,11 +10,14 @@ export class CocoaPodsPackageManager implements PackageManager {
private log: Logger;
private silent: boolean;

static getPodProjectRoot(projectRoot: string): string | null {
if (CocoaPodsPackageManager.isUsingPods(projectRoot)) return projectRoot;
const iosProject = path.join(projectRoot, 'ios');
if (CocoaPodsPackageManager.isUsingPods(iosProject)) return iosProject;
return null;
}

static isUsingPods(projectRoot: string): boolean {
const workspaceRoot = findWorkspaceRoot(projectRoot);
if (workspaceRoot) {
return fs.existsSync(path.join(workspaceRoot, 'ios', 'Podfile'));
}
return fs.existsSync(path.join(projectRoot, 'Podfile'));
}

Expand Down
6 changes: 5 additions & 1 deletion packages/pod-install/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@ async function runAsync(): Promise<void> {
console.log(chalk.red('CocoaPods is only supported on darwin machines'));
return;
}
if (!CocoaPodsPackageManager.isUsingPods(projectRoot)) {

const possibleProjectRoot = CocoaPodsPackageManager.getPodProjectRoot(projectRoot);
if (!possibleProjectRoot) {
console.log(chalk.yellow('CocoaPods is not supported in this project'));
return;
} else {
projectRoot = possibleProjectRoot;
}

if (!(await CocoaPodsPackageManager.isCLIInstalledAsync())) {
Expand Down

0 comments on commit 4c41e0a

Please sign in to comment.