MCPcopy Create free account
hub / github.com/reactnativecn/react-native-update / findNewestHar

Function findNewestHar

scripts/build-harmony-har.js:399–432  ·  view source on GitHub ↗
(rootDir)

Source from the content-addressed store, hash-verified

397}
398
399function findNewestHar(rootDir) {
400 if (!fs.existsSync(rootDir)) {
401 return null;
402 }
403
404 let latestFile = null;
405 let latestMtime = 0;
406 const queue = [rootDir];
407
408 while (queue.length > 0) {
409 const currentDir = queue.pop();
410 const entries = fs.readdirSync(currentDir, { withFileTypes: true });
411
412 for (const entry of entries) {
413 const fullPath = path.join(currentDir, entry.name);
414 if (entry.isDirectory()) {
415 queue.push(fullPath);
416 continue;
417 }
418
419 if (!entry.isFile() || !entry.name.endsWith('.har')) {
420 continue;
421 }
422
423 const stat = fs.statSync(fullPath);
424 if (!latestFile || stat.mtimeMs > latestMtime) {
425 latestFile = fullPath;
426 latestMtime = stat.mtimeMs;
427 }
428 }
429 }
430
431 return latestFile;
432}
433
434function ensureFileExists(filePath, message) {
435 if (!fs.existsSync(filePath)) {

Callers 1

buildHarFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected