@@ -23,6 +23,32 @@ const platformOption = new Option(
2323 "The React Native package to vendor Hermes into" ,
2424) . default ( "react-native" ) ;
2525
26+ type PatchJSIHeadersOptions = {
27+ reactNativePath : string ;
28+ hermesJsiPath : string ;
29+ silent : boolean ;
30+ } ;
31+
32+ async function patchJsiHeaders ( {
33+ reactNativePath,
34+ hermesJsiPath,
35+ silent,
36+ } : PatchJSIHeadersOptions ) {
37+ const reactNativeJsiPath = path . join ( reactNativePath , "ReactCommon/jsi/jsi/" ) ;
38+ await oraPromise (
39+ fs . promises . cp ( hermesJsiPath , reactNativeJsiPath , {
40+ recursive : true ,
41+ } ) ,
42+ {
43+ text : `Copying JSI from patched Hermes to React Native` ,
44+ successText : "Copied JSI from patched Hermes to React Native" ,
45+ failText : ( err ) =>
46+ `Failed to copy JSI from Hermes to React Native: ${ err . message } ` ,
47+ isEnabled : ! silent ,
48+ } ,
49+ ) ;
50+ }
51+
2652export const command = new Command ( "vendor-hermes" )
2753 . argument ( "[from]" , "Path to a file inside the app package" , process . cwd ( ) )
2854 . option ( "--silent" , "Don't print anything except the final path" , false )
@@ -64,11 +90,6 @@ export const command = new Command("vendor-hermes")
6490 console . log ( `Using Hermes version: ${ hermesVersion } ` ) ;
6591 }
6692
67- const reactNativeJsiPath = path . join (
68- reactNativePath ,
69- "ReactCommon/jsi/jsi/" ,
70- ) ;
71-
7293 const hermesPath = path . join ( reactNativePath , "sdks" , "node-api-hermes" ) ;
7394 if ( force && fs . existsSync ( hermesPath ) ) {
7495 await oraPromise (
@@ -125,19 +146,11 @@ export const command = new Command("vendor-hermes")
125146 fs . existsSync ( hermesJsiPath ) ,
126147 `Hermes JSI path does not exist: ${ hermesJsiPath } ` ,
127148 ) ;
128-
129- await oraPromise (
130- fs . promises . cp ( hermesJsiPath , reactNativeJsiPath , {
131- recursive : true ,
132- } ) ,
133- {
134- text : `Copying JSI from patched Hermes to React Native` ,
135- successText : "Copied JSI from patched Hermes to React Native" ,
136- failText : ( err ) =>
137- `Failed to copy JSI from Hermes to React Native: ${ err . message } ` ,
138- isEnabled : ! silent ,
139- } ,
140- ) ;
149+ await patchJsiHeaders ( {
150+ reactNativePath,
151+ hermesJsiPath,
152+ silent,
153+ } ) ;
141154 console . log ( hermesPath ) ;
142155 } ) ,
143156 ) ;
0 commit comments