Skip to content

Commit

Permalink
feat: add customize protoc release url (#658)
Browse files Browse the repository at this point in the history
Co-authored-by: shixia.ly <[email protected]>
  • Loading branch information
akitaSummer and shixia.ly authored Nov 4, 2024
1 parent be338a8 commit 8a508df
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/protoc/protoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,12 @@ async function main() {


async function ensureInstalled(version) {
const releaseUrl = process.env.PROTOC_RELEASES_URL || "https://github.com/protocolbuffers/protobuf/releases";
// resolve the latest release version number if necessary
if (version === "latest" || version === undefined) {
let latestLocation;
try {
latestLocation = await httpGetRedirect("https://github.com/protocolbuffers/protobuf/releases/latest");
latestLocation = await httpGetRedirect(`${releaseUrl}/latest`);
} catch (e) {
throw new Error(`@protobuf-ts/protoc failed to retrieve latest protoc version number: ${e}`);
}
Expand All @@ -105,7 +106,7 @@ async function ensureInstalled(version) {
// download the release
let archive;
try {
archive = await httpDownload(`https://github.com/protocolbuffers/protobuf/releases/download/v${version}/${releaseName}.zip`);
archive = await httpDownload(`${releaseUrl}/download/v${version}/${releaseName}.zip`);
} catch (e) {
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}`);
}
Expand Down

0 comments on commit 8a508df

Please sign in to comment.