@@ -221,8 +221,7 @@ function processStable(buildDir) {
221221 ) ;
222222 }
223223
224- const rnVersionString =
225- ReactVersion + '-native-fb-' + sha + '-' + dateString ;
224+ const rnVersionString = ReactVersion + '-native-fb-' + sha + '-' + dateString ;
226225 if ( fs . existsSync ( buildDir + '/facebook-react-native' ) ) {
227226 updatePlaceholderReactVersionInCompiledArtifacts (
228227 buildDir + '/facebook-react-native' ,
@@ -231,9 +230,16 @@ function processStable(buildDir) {
231230 }
232231
233232 if ( fs . existsSync ( buildDir + '/react-native' ) ) {
234- updatePlaceholderReactVersionInCompiledArtifactsFb (
233+ updatePlaceholderReactVersionInCompiledArtifacts (
235234 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' )
237243 ) ;
238244 }
239245
@@ -340,9 +346,16 @@ function processExperimental(buildDir, version) {
340346 }
341347
342348 if ( fs . existsSync ( buildDir + '/react-native' ) ) {
343- updatePlaceholderReactVersionInCompiledArtifactsFb (
349+ updatePlaceholderReactVersionInCompiledArtifacts (
344350 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' )
346359 ) ;
347360 }
348361
@@ -437,38 +450,15 @@ function updatePackageVersions(
437450
438451function updatePlaceholderReactVersionInCompiledArtifacts (
439452 artifactsDirectory ,
440- newVersion
453+ newVersion ,
454+ filteringClosure
441455) {
442456 // Update the version of React in the compiled artifacts by searching for
443457 // 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' )
463460 }
464- }
465461
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.
472462 const artifactFilenames = String (
473463 spawnSync ( 'grep' , [
474464 '-lr' ,
@@ -479,7 +469,7 @@ function updatePlaceholderReactVersionInCompiledArtifactsFb(
479469 )
480470 . trim ( )
481471 . split ( '\n' )
482- . filter ( filename => filename . endsWith ( '.fb.js' ) ) ;
472+ . filter ( filteringClosure ) ;
483473
484474 for ( const artifactFilename of artifactFilenames ) {
485475 const originalText = fs . readFileSync ( artifactFilename , 'utf8' ) ;
@@ -491,6 +481,7 @@ function updatePlaceholderReactVersionInCompiledArtifactsFb(
491481 }
492482}
493483
484+
494485/**
495486 * cross-platform alternative to `rsync -ar`
496487 * @param {string } source
0 commit comments