@@ -57,6 +57,26 @@ export function compareMd5Hashes(hash1: string, hash2: string) {
57
57
return hash1 === hash2 ;
58
58
}
59
59
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
+
60
80
export default async function resolvePods (
61
81
root : string ,
62
82
nativeDependencies : NativeDependencies ,
@@ -77,28 +97,15 @@ export default async function resolvePods(
77
97
'dependencies' ,
78
98
) ;
79
99
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 (
81
105
! cachedDependenciesHash ||
82
106
! compareMd5Hashes ( currentDependenciesHash , cachedDependenciesHash ) ||
83
- ! arePodsInstalled ||
84
- options ?. forceInstall
107
+ ! arePodsInstalled
85
108
) {
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 ) ;
103
110
}
104
111
}
0 commit comments