Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add customize protoc release url #658

Merged
merged 1 commit into from
Nov 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading