From 58306756c7a9d1303d27cfca29b591db0860d95c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=A6n=20Hansen?= Date: Tue, 28 Oct 2025 11:09:42 +0100 Subject: [PATCH] Moved patching of JSI headers to a separate function --- packages/host/src/node/cli/hermes.ts | 49 ++++++++++++++++++---------- 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/packages/host/src/node/cli/hermes.ts b/packages/host/src/node/cli/hermes.ts index 6bd3daa3..4b41692c 100644 --- a/packages/host/src/node/cli/hermes.ts +++ b/packages/host/src/node/cli/hermes.ts @@ -23,6 +23,32 @@ const platformOption = new Option( "The React Native package to vendor Hermes into", ).default("react-native"); +type PatchJSIHeadersOptions = { + reactNativePath: string; + hermesJsiPath: string; + silent: boolean; +}; + +async function patchJsiHeaders({ + reactNativePath, + hermesJsiPath, + silent, +}: PatchJSIHeadersOptions) { + const reactNativeJsiPath = path.join(reactNativePath, "ReactCommon/jsi/jsi/"); + await oraPromise( + fs.promises.cp(hermesJsiPath, reactNativeJsiPath, { + recursive: true, + }), + { + text: `Copying JSI from patched Hermes to React Native`, + successText: "Copied JSI from patched Hermes to React Native", + failText: (err) => + `Failed to copy JSI from Hermes to React Native: ${err.message}`, + isEnabled: !silent, + }, + ); +} + export const command = new Command("vendor-hermes") .argument("[from]", "Path to a file inside the app package", process.cwd()) .option("--silent", "Don't print anything except the final path", false) @@ -64,11 +90,6 @@ export const command = new Command("vendor-hermes") console.log(`Using Hermes version: ${hermesVersion}`); } - const reactNativeJsiPath = path.join( - reactNativePath, - "ReactCommon/jsi/jsi/", - ); - const hermesPath = path.join(reactNativePath, "sdks", "node-api-hermes"); if (force && fs.existsSync(hermesPath)) { await oraPromise( @@ -125,19 +146,11 @@ export const command = new Command("vendor-hermes") fs.existsSync(hermesJsiPath), `Hermes JSI path does not exist: ${hermesJsiPath}`, ); - - await oraPromise( - fs.promises.cp(hermesJsiPath, reactNativeJsiPath, { - recursive: true, - }), - { - text: `Copying JSI from patched Hermes to React Native`, - successText: "Copied JSI from patched Hermes to React Native", - failText: (err) => - `Failed to copy JSI from Hermes to React Native: ${err.message}`, - isEnabled: !silent, - }, - ); + await patchJsiHeaders({ + reactNativePath, + hermesJsiPath, + silent, + }); console.log(hermesPath); }), );