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: skip pods installation when it's already installed #2112

Merged
Merged
Changes from all 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
47 changes: 27 additions & 20 deletions packages/cli-platform-ios/src/tools/pods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,26 @@ export function compareMd5Hashes(hash1: string, hash2: string) {
return hash1 === hash2;
}

async function install(
packageJson: Record<string, any>,
cachedDependenciesHash: string | undefined,
currentDependenciesHash: string,
) {
const loader = getLoader('Installing CocoaPods...');
try {
await installPods(loader, {skipBundleInstall: !!cachedDependenciesHash});
cacheManager.set(packageJson.name, 'dependencies', currentDependenciesHash);
loader.succeed();
} catch {
loader.fail();
throw new CLIError(
`Something when wrong while installing CocoaPods. Please run ${chalk.bold(
'pod install',
)} manually`,
);
}
}

export default async function resolvePods(
root: string,
nativeDependencies: NativeDependencies,
Expand All @@ -77,28 +97,15 @@ export default async function resolvePods(
'dependencies',
);

if (
if (options?.forceInstall) {
await install(packageJson, cachedDependenciesHash, currentDependenciesHash);
} else if (arePodsInstalled && cachedDependenciesHash === undefined) {
cacheManager.set(packageJson.name, 'dependencies', currentDependenciesHash);
} else if (
!cachedDependenciesHash ||
!compareMd5Hashes(currentDependenciesHash, cachedDependenciesHash) ||
!arePodsInstalled ||
options?.forceInstall
!arePodsInstalled
) {
const loader = getLoader('Installing CocoaPods...');
try {
await installPods(loader, {skipBundleInstall: !!cachedDependenciesHash});
cacheManager.set(
packageJson.name,
'dependencies',
currentDependenciesHash,
);
loader.succeed();
} catch {
loader.fail();
throw new CLIError(
`Something when wrong while installing CocoaPods. Please run ${chalk.bold(
'pod install',
)} manually`,
);
}
await install(packageJson, cachedDependenciesHash, currentDependenciesHash);
}
}