Skip to content

Commit 8a508df

Browse files
akitaSummershixia.ly
andauthored
feat: add customize protoc release url (#658)
Co-authored-by: shixia.ly <[email protected]>
1 parent be338a8 commit 8a508df

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/protoc/protoc.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,12 @@ async function main() {
7878

7979

8080
async function ensureInstalled(version) {
81+
const releaseUrl = process.env.PROTOC_RELEASES_URL || "https://github.com/protocolbuffers/protobuf/releases";
8182
// resolve the latest release version number if necessary
8283
if (version === "latest" || version === undefined) {
8384
let latestLocation;
8485
try {
85-
latestLocation = await httpGetRedirect("https://github.com/protocolbuffers/protobuf/releases/latest");
86+
latestLocation = await httpGetRedirect(`${releaseUrl}/latest`);
8687
} catch (e) {
8788
throw new Error(`@protobuf-ts/protoc failed to retrieve latest protoc version number: ${e}`);
8889
}
@@ -105,7 +106,7 @@ async function ensureInstalled(version) {
105106
// download the release
106107
let archive;
107108
try {
108-
archive = await httpDownload(`https://github.com/protocolbuffers/protobuf/releases/download/v${version}/${releaseName}.zip`);
109+
archive = await httpDownload(`${releaseUrl}/download/v${version}/${releaseName}.zip`);
109110
} catch (e) {
110111
throw new Error(`@protobuf-ts/protoc failed to download protoc v${version}. \nDid you misspell the version number? The version number must look like "3.0.12", without a leading "v".\n${e}`);
111112
}

0 commit comments

Comments
 (0)