Avoid creating too many unnecessary build directories for Fantom bundles (#52788)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52788

Changelog: [internal]

Minor change to just create a single output directory for generated JS code in Fantom per Jest run.

Reviewed By: lenaic

Differential Revision: D78808564

fbshipit-source-id: 70e1a60dfcdcc3fc6ee5f08ced1e9c8f8cab2782
This commit is contained in:
Rubén Norte
2025-07-25 05:47:35 -07:00
committed by Facebook GitHub Bot
parent 2c683c5787
commit 0f7ba79166
2 changed files with 12 additions and 4 deletions
@@ -15,6 +15,8 @@ export default async function globalSetup(
globalConfig: {...},
projectConfig: {...},
): Promise<void> {
process.env.__FANTOM_RUN_ID__ ??= `run-${Date.now()}`;
validateEnvironmentVariables();
if (!isOSS) {
+10 -4
View File
@@ -51,11 +51,17 @@ import nullthrows from 'nullthrows';
import path from 'path';
import readline from 'readline';
const fantomRunID = process.env.__FANTOM_RUN_ID__;
if (fantomRunID == null) {
throw new Error(
'Expected Fantom run ID to be set by global setup, but it was not (process.env.__FANTOM_RUN_ID__ is null)',
);
}
const BUILD_OUTPUT_ROOT = path.resolve(__dirname, '..', 'build', 'js');
fs.mkdirSync(BUILD_OUTPUT_ROOT, {recursive: true});
const BUILD_OUTPUT_PATH = fs.mkdtempSync(
path.join(BUILD_OUTPUT_ROOT, `run-${Date.now()}-`),
);
const BUILD_OUTPUT_PATH = path.join(BUILD_OUTPUT_ROOT, fantomRunID);
fs.mkdirSync(BUILD_OUTPUT_PATH, {recursive: true});
function buildError(
failureDetail: FailureDetail,