Skip to content

Commit 0f7ba79

Browse files
rubennortefacebook-github-bot
authored andcommitted
Avoid creating too many unnecessary build directories for Fantom bundles (facebook#52788)
Summary: Pull Request resolved: facebook#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
1 parent 2c683c5 commit 0f7ba79

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

private/react-native-fantom/runner/global-setup/globalSetup.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export default async function globalSetup(
1515
globalConfig: {...},
1616
projectConfig: {...},
1717
): Promise<void> {
18+
process.env.__FANTOM_RUN_ID__ ??= `run-${Date.now()}`;
19+
1820
validateEnvironmentVariables();
1921

2022
if (!isOSS) {

private/react-native-fantom/runner/runner.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,17 @@ import nullthrows from 'nullthrows';
5151
import path from 'path';
5252
import readline from 'readline';
5353

54+
const fantomRunID = process.env.__FANTOM_RUN_ID__;
55+
if (fantomRunID == null) {
56+
throw new Error(
57+
'Expected Fantom run ID to be set by global setup, but it was not (process.env.__FANTOM_RUN_ID__ is null)',
58+
);
59+
}
60+
5461
const BUILD_OUTPUT_ROOT = path.resolve(__dirname, '..', 'build', 'js');
55-
fs.mkdirSync(BUILD_OUTPUT_ROOT, {recursive: true});
56-
const BUILD_OUTPUT_PATH = fs.mkdtempSync(
57-
path.join(BUILD_OUTPUT_ROOT, `run-${Date.now()}-`),
58-
);
62+
const BUILD_OUTPUT_PATH = path.join(BUILD_OUTPUT_ROOT, fantomRunID);
63+
64+
fs.mkdirSync(BUILD_OUTPUT_PATH, {recursive: true});
5965

6066
function buildError(
6167
failureDetail: FailureDetail,

0 commit comments

Comments
 (0)