Use fileExists in replace_hermes script (#37911)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37911

Thanks to [adrianha](https://github.com/adrianha) for spotting a bug in the script that replace the Hermes engine.
I miscopied the variable to check when there is no previous build file.

This change uses the right variable and improves also the messages printed to the user.

## Changelog:
[Internal] - Fix replace_hermes_version script using the right `fileExists` variable

Reviewed By: dmytrorykun

Differential Revision: D46762041

fbshipit-source-id: fdf3da6a598ecc657ee9313a2fa41e71c01d14ce
This commit is contained in:
Riccardo Cipolleschi
2023-06-15 07:27:57 -07:00
committed by Facebook GitHub Bot
parent 7d4f233db3
commit 09c95413dd
@@ -34,15 +34,17 @@ function shouldReplaceHermesConfiguration(configuration) {
console.log(`Found ${LAST_BUILD_FILENAME} file`);
const oldConfiguration = fs.readFileSync(LAST_BUILD_FILENAME).toString();
if (oldConfiguration === configuration) {
console.log('No need to download a new build of Hermes!');
console.log(
'Same config of the previous build. No need to replace Hermes engine',
);
return false;
}
}
// Assumption: if there is no stored last build, we assume that it was build for debug.
if (!fs.existsSync && configuration === 'Debug') {
if (!fileExists && configuration === 'Debug') {
console.log(
'File does not exists, but Debug configuration. No need to download a new build of Hermes!',
'No previous build detected, but Debug Configuration. No need to replace Hermes engine',
);
return false;
}