Skip to content

Commit

Permalink
fix: simplify receiving checksum from Podfile
Browse files Browse the repository at this point in the history
  • Loading branch information
szymonrybczak committed Jul 9, 2024
1 parent 58a0652 commit c829229
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions packages/cli-platform-apple/src/tools/pods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
IOSDependencyConfig,
} from '@react-native-community/cli-types';
import {ApplePlatform} from '../types';
import readline from 'readline';

interface ResolvePodsOptions {
forceInstall?: boolean;
Expand Down Expand Up @@ -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<string | undefined> {
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(
Expand Down

0 comments on commit c829229

Please sign in to comment.