Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rickhanlonii committed Jun 6, 2024
1 parent 883716d commit 25f9c80
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions scripts/rollup/build-all-release-channels.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ function processStable(buildDir) {
}

if (fs.existsSync(buildDir + '/react-native')) {
updatePlaceholderReactVersionInCompiledArtifacts(
buildDir + '/react-native/implementations/**.fb.js',
updatePlaceholderReactVersionInCompiledArtifactsFb(
buildDir + '/react-native',
rnVersionString
);
}
Expand Down Expand Up @@ -287,8 +287,8 @@ function processExperimental(buildDir, version) {
}

if (fs.existsSync(buildDir + '/react-native')) {
updatePlaceholderReactVersionInCompiledArtifacts(
buildDir + '/react-native/implementations/**.fb.js',
updatePlaceholderReactVersionInCompiledArtifactsFb(
buildDir + '/react-native',
rnVersionString
);
}
Expand Down Expand Up @@ -410,6 +410,34 @@ function updatePlaceholderReactVersionInCompiledArtifacts(
}
}

function updatePlaceholderReactVersionInCompiledArtifactsFb(
artifactsDirectory,
newVersion
) {
// Update the version of React in the compiled artifacts by searching for
// the placeholder string and replacing it with a new one.
const artifactFilenames = String(
spawnSync('grep', [
'-lr',
PLACEHOLDER_REACT_VERSION,
'--',
artifactsDirectory,
]).stdout
)
.trim()
.split('\n')
.filter(filename => filename.endsWith('.fb.js'));

for (const artifactFilename of artifactFilenames) {
const originalText = fs.readFileSync(artifactFilename, 'utf8');
const replacedText = originalText.replaceAll(
PLACEHOLDER_REACT_VERSION,
newVersion
);
fs.writeFileSync(artifactFilename, replacedText);
}
}

/**
* cross-platform alternative to `rsync -ar`
* @param {string} source
Expand Down

0 comments on commit 25f9c80

Please sign in to comment.