@@ -168,12 +168,19 @@ function processStable(buildDir) {
168
168
) ;
169
169
}
170
170
171
+ const rnVersionString =
172
+ ReactVersion + '-native-fb-' + sha + '-' + dateString ;
171
173
if ( fs . existsSync ( buildDir + '/facebook-react-native' ) ) {
172
- const versionString =
173
- ReactVersion + '-native-fb-' + sha + '-' + dateString ;
174
174
updatePlaceholderReactVersionInCompiledArtifacts (
175
175
buildDir + '/facebook-react-native' ,
176
- versionString
176
+ rnVersionString
177
+ ) ;
178
+ }
179
+
180
+ if ( fs . existsSync ( buildDir + '/react-native' ) ) {
181
+ updatePlaceholderReactVersionInCompiledArtifactsFb (
182
+ buildDir + '/react-native' ,
183
+ rnVersionString
177
184
) ;
178
185
}
179
186
@@ -265,17 +272,24 @@ function processExperimental(buildDir, version) {
265
272
fs . writeFileSync ( buildDir + '/facebook-www/VERSION_MODERN' , versionString ) ;
266
273
}
267
274
275
+ const rnVersionString = ReactVersion + '-native-fb-' + sha + '-' + dateString ;
268
276
if ( fs . existsSync ( buildDir + '/facebook-react-native' ) ) {
269
- const versionString = ReactVersion + '-native-fb-' + sha + '-' + dateString ;
270
277
updatePlaceholderReactVersionInCompiledArtifacts (
271
278
buildDir + '/facebook-react-native' ,
272
- versionString
279
+ rnVersionString
273
280
) ;
274
281
275
282
// Also save a file with the version number
276
283
fs . writeFileSync (
277
284
buildDir + '/facebook-react-native/VERSION_NATIVE_FB' ,
278
- versionString
285
+ rnVersionString
286
+ ) ;
287
+ }
288
+
289
+ if ( fs . existsSync ( buildDir + '/react-native' ) ) {
290
+ updatePlaceholderReactVersionInCompiledArtifactsFb (
291
+ buildDir + '/react-native' ,
292
+ rnVersionString
279
293
) ;
280
294
}
281
295
@@ -396,6 +410,34 @@ function updatePlaceholderReactVersionInCompiledArtifacts(
396
410
}
397
411
}
398
412
413
+ function updatePlaceholderReactVersionInCompiledArtifactsFb (
414
+ artifactsDirectory ,
415
+ newVersion
416
+ ) {
417
+ // Update the version of React in the compiled artifacts by searching for
418
+ // the placeholder string and replacing it with a new one.
419
+ const artifactFilenames = String (
420
+ spawnSync ( 'grep' , [
421
+ '-lr' ,
422
+ PLACEHOLDER_REACT_VERSION ,
423
+ '--' ,
424
+ artifactsDirectory ,
425
+ ] ) . stdout
426
+ )
427
+ . trim ( )
428
+ . split ( '\n' )
429
+ . filter ( filename => filename . endsWith ( '.fb.js' ) ) ;
430
+
431
+ for ( const artifactFilename of artifactFilenames ) {
432
+ const originalText = fs . readFileSync ( artifactFilename , 'utf8' ) ;
433
+ const replacedText = originalText . replaceAll (
434
+ PLACEHOLDER_REACT_VERSION ,
435
+ newVersion
436
+ ) ;
437
+ fs . writeFileSync ( artifactFilename , replacedText ) ;
438
+ }
439
+ }
440
+
399
441
/**
400
442
* cross-platform alternative to `rsync -ar`
401
443
* @param {string } source
0 commit comments