-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Expand file tree
/
Copy pathselectLatestHermesV1Version.js
More file actions
38 lines (31 loc) · 1.12 KB
/
Copy pathselectLatestHermesV1Version.js
File metadata and controls
38 lines (31 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
const { execSync } = require('child_process');
const fs = require('fs');
const path = require('path');
const PATCH_FILE_PATH = path.join(__dirname, 'hermes-v1.patch');
function getLatestHermesV1Version() {
const npmString = "npm view hermes-compiler@latest-v1 version";
try {
const result = execSync(npmString, { stdio: ['ignore', 'pipe', 'ignore'] }).toString().trim();
return result;
} catch (error) {
throw new Error(`Failed to get package version for hermes-compiler@latest-v1`);
}
}
function setHermesV1VersionInPatch(version) {
if (!fs.existsSync(PATCH_FILE_PATH)) {
throw new Error(`Patch file not found at path: ${PATCH_FILE_PATH}`);
}
let patchContent = fs.readFileSync(PATCH_FILE_PATH, 'utf8');
const updatedContent = patchContent.replaceAll(
"$HERMES_V1_VERSION",
version
);
fs.writeFileSync(PATCH_FILE_PATH, updatedContent, 'utf8');
}
setHermesV1VersionInPatch(getLatestHermesV1Version());