Skip to content

Commit abe0d1e

Browse files
fix: skip pods installation when it's already installed (#2112)
1 parent 604795d commit abe0d1e

File tree

1 file changed

+27
-20
lines changed
  • packages/cli-platform-ios/src/tools

1 file changed

+27
-20
lines changed

packages/cli-platform-ios/src/tools/pods.ts

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,26 @@ export function compareMd5Hashes(hash1: string, hash2: string) {
5757
return hash1 === hash2;
5858
}
5959

60+
async function install(
61+
packageJson: Record<string, any>,
62+
cachedDependenciesHash: string | undefined,
63+
currentDependenciesHash: string,
64+
) {
65+
const loader = getLoader('Installing CocoaPods...');
66+
try {
67+
await installPods(loader, {skipBundleInstall: !!cachedDependenciesHash});
68+
cacheManager.set(packageJson.name, 'dependencies', currentDependenciesHash);
69+
loader.succeed();
70+
} catch {
71+
loader.fail();
72+
throw new CLIError(
73+
`Something when wrong while installing CocoaPods. Please run ${chalk.bold(
74+
'pod install',
75+
)} manually`,
76+
);
77+
}
78+
}
79+
6080
export default async function resolvePods(
6181
root: string,
6282
nativeDependencies: NativeDependencies,
@@ -77,28 +97,15 @@ export default async function resolvePods(
7797
'dependencies',
7898
);
7999

80-
if (
100+
if (options?.forceInstall) {
101+
await install(packageJson, cachedDependenciesHash, currentDependenciesHash);
102+
} else if (arePodsInstalled && cachedDependenciesHash === undefined) {
103+
cacheManager.set(packageJson.name, 'dependencies', currentDependenciesHash);
104+
} else if (
81105
!cachedDependenciesHash ||
82106
!compareMd5Hashes(currentDependenciesHash, cachedDependenciesHash) ||
83-
!arePodsInstalled ||
84-
options?.forceInstall
107+
!arePodsInstalled
85108
) {
86-
const loader = getLoader('Installing CocoaPods...');
87-
try {
88-
await installPods(loader, {skipBundleInstall: !!cachedDependenciesHash});
89-
cacheManager.set(
90-
packageJson.name,
91-
'dependencies',
92-
currentDependenciesHash,
93-
);
94-
loader.succeed();
95-
} catch {
96-
loader.fail();
97-
throw new CLIError(
98-
`Something when wrong while installing CocoaPods. Please run ${chalk.bold(
99-
'pod install',
100-
)} manually`,
101-
);
102-
}
109+
await install(packageJson, cachedDependenciesHash, currentDependenciesHash);
103110
}
104111
}

0 commit comments

Comments
 (0)