@@ -221,8 +221,7 @@ function processStable(buildDir) {
221
221
) ;
222
222
}
223
223
224
- const rnVersionString =
225
- ReactVersion + '-native-fb-' + sha + '-' + dateString ;
224
+ const rnVersionString = ReactVersion + '-native-fb-' + sha + '-' + dateString ;
226
225
if ( fs . existsSync ( buildDir + '/facebook-react-native' ) ) {
227
226
updatePlaceholderReactVersionInCompiledArtifacts (
228
227
buildDir + '/facebook-react-native' ,
@@ -231,9 +230,16 @@ function processStable(buildDir) {
231
230
}
232
231
233
232
if ( fs . existsSync ( buildDir + '/react-native' ) ) {
234
- updatePlaceholderReactVersionInCompiledArtifactsFb (
233
+ updatePlaceholderReactVersionInCompiledArtifacts (
235
234
buildDir + '/react-native' ,
236
- rnVersionString
235
+ rnVersionString ,
236
+ ( filename ) => filename . endsWith ( '.fb.js' )
237
+ ) ;
238
+
239
+ updatePlaceholderReactVersionInCompiledArtifacts (
240
+ buildDir + '/react-native' ,
241
+ ReactVersion ,
242
+ ( filename ) => ! filename . endsWith ( '.fb.js' ) && filename . endsWith ( '.js' )
237
243
) ;
238
244
}
239
245
@@ -340,9 +346,16 @@ function processExperimental(buildDir, version) {
340
346
}
341
347
342
348
if ( fs . existsSync ( buildDir + '/react-native' ) ) {
343
- updatePlaceholderReactVersionInCompiledArtifactsFb (
349
+ updatePlaceholderReactVersionInCompiledArtifacts (
344
350
buildDir + '/react-native' ,
345
- rnVersionString
351
+ rnVersionString ,
352
+ ( filename ) => filename . endsWith ( '.fb.js' )
353
+ ) ;
354
+
355
+ updatePlaceholderReactVersionInCompiledArtifacts (
356
+ buildDir + '/react-native' ,
357
+ ReactVersion ,
358
+ ( filename ) => ! filename . endsWith ( '.fb.js' ) && filename . endsWith ( '.js' )
346
359
) ;
347
360
}
348
361
@@ -437,38 +450,15 @@ function updatePackageVersions(
437
450
438
451
function updatePlaceholderReactVersionInCompiledArtifacts (
439
452
artifactsDirectory ,
440
- newVersion
453
+ newVersion ,
454
+ filteringClosure
441
455
) {
442
456
// Update the version of React in the compiled artifacts by searching for
443
457
// the placeholder string and replacing it with a new one.
444
- const artifactFilenames = String (
445
- spawnSync ( 'grep' , [
446
- '-lr' ,
447
- PLACEHOLDER_REACT_VERSION ,
448
- '--' ,
449
- artifactsDirectory ,
450
- ] ) . stdout
451
- )
452
- . trim ( )
453
- . split ( '\n' )
454
- . filter ( filename => filename . endsWith ( '.js' ) ) ;
455
-
456
- for ( const artifactFilename of artifactFilenames ) {
457
- const originalText = fs . readFileSync ( artifactFilename , 'utf8' ) ;
458
- const replacedText = originalText . replaceAll (
459
- PLACEHOLDER_REACT_VERSION ,
460
- newVersion
461
- ) ;
462
- fs . writeFileSync ( artifactFilename , replacedText ) ;
458
+ if ( filteringClosure == null ) {
459
+ filteringClosure = filename => filename . endsWith ( '.js' )
463
460
}
464
- }
465
461
466
- function updatePlaceholderReactVersionInCompiledArtifactsFb (
467
- artifactsDirectory ,
468
- newVersion
469
- ) {
470
- // Update the version of React in the compiled artifacts by searching for
471
- // the placeholder string and replacing it with a new one.
472
462
const artifactFilenames = String (
473
463
spawnSync ( 'grep' , [
474
464
'-lr' ,
@@ -479,7 +469,7 @@ function updatePlaceholderReactVersionInCompiledArtifactsFb(
479
469
)
480
470
. trim ( )
481
471
. split ( '\n' )
482
- . filter ( filename => filename . endsWith ( '.fb.js' ) ) ;
472
+ . filter ( filteringClosure ) ;
483
473
484
474
for ( const artifactFilename of artifactFilenames ) {
485
475
const originalText = fs . readFileSync ( artifactFilename , 'utf8' ) ;
@@ -491,6 +481,7 @@ function updatePlaceholderReactVersionInCompiledArtifactsFb(
491
481
}
492
482
}
493
483
484
+
494
485
/**
495
486
* cross-platform alternative to `rsync -ar`
496
487
* @param {string } source
0 commit comments