Skip to content

Commit

Permalink
fix: skip pods installation when it's already installed (#2112)
Browse files Browse the repository at this point in the history
  • Loading branch information
TMisiukiewicz authored Oct 19, 2023
1 parent 604795d commit abe0d1e
Showing 1 changed file with 27 additions and 20 deletions.
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);
}
}

0 comments on commit abe0d1e

Please sign in to comment.