From 5abea6e43d9b706e1bad19803baed31505c4ec5d Mon Sep 17 00:00:00 2001 From: szymonrybczak Date: Tue, 9 Jul 2024 14:40:28 +0200 Subject: [PATCH] fix: simplify receiving checksum from `Podfile` --- packages/cli-platform-apple/src/tools/pods.ts | 29 +++++++------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/packages/cli-platform-apple/src/tools/pods.ts b/packages/cli-platform-apple/src/tools/pods.ts index c5deed972..495ad52fd 100644 --- a/packages/cli-platform-apple/src/tools/pods.ts +++ b/packages/cli-platform-apple/src/tools/pods.ts @@ -13,7 +13,6 @@ import { IOSDependencyConfig, } from '@react-native-community/cli-types'; import {ApplePlatform} from '../types'; -import readline from 'readline'; interface ResolvePodsOptions { forceInstall?: boolean; @@ -65,26 +64,20 @@ export function compareMd5Hashes(hash1?: string, hash2?: string) { return hash1 === hash2; } -async function getChecksum(podfileLockPath: string) { - const fileStream = fs.createReadStream(podfileLockPath); +async function getChecksum( + podfileLockPath: string, +): Promise { + const file = fs.readFileSync(podfileLockPath, 'utf8'); - const rl = readline.createInterface({ - input: fileStream, - crlfDelay: Infinity, - }); + const checksumLine = file + .split('\n') + .find((line) => line.includes('PODFILE CHECKSUM')); - let lines = []; - for await (const line of rl) { - lines.push(line); + if (checksumLine) { + return checksumLine.split(': ')[1]; + } else { + return undefined; } - - lines = lines.reverse(); - - return lines - .filter((line) => line.includes('PODFILE CHECKSUM'))[0] - .split(': ')[1] - - return undefined; } async function install(