Skip to content

Commit 5ca9b77

Browse files
Copilotshouze
andcommitted
Fix upgrade failing on macOS due to platform name mismatch (darwin→macos, win32→windows)
Co-authored-by: shouze <54712+shouze@users.noreply.github.com>
1 parent 6484c26 commit 5ca9b77

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

src/upgrade.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,21 @@ function makeAsset(name: string): ReleaseAsset {
5353

5454
describe("selectAsset", () => {
5555
const assets: ReleaseAsset[] = [
56-
makeAsset("github-code-search-darwin-arm64"),
57-
makeAsset("github-code-search-darwin-x64"),
56+
makeAsset("github-code-search-macos-arm64"),
57+
makeAsset("github-code-search-macos-x64"),
5858
makeAsset("github-code-search-linux-x64"),
5959
makeAsset("github-code-search-linux-arm64"),
60-
makeAsset("github-code-search-win32-x64.exe"),
60+
makeAsset("github-code-search-windows-x64.exe"),
6161
];
6262

63-
it("selects darwin-arm64 asset", () => {
63+
it("selects macos-arm64 asset for darwin/arm64", () => {
6464
const asset = selectAsset(assets, "darwin", "arm64");
65-
expect(asset?.name).toBe("github-code-search-darwin-arm64");
65+
expect(asset?.name).toBe("github-code-search-macos-arm64");
6666
});
6767

68-
it("selects darwin-x64 asset", () => {
68+
it("selects macos-x64 asset for darwin/x64", () => {
6969
const asset = selectAsset(assets, "darwin", "x64");
70-
expect(asset?.name).toBe("github-code-search-darwin-x64");
70+
expect(asset?.name).toBe("github-code-search-macos-x64");
7171
});
7272

7373
it("selects linux-x64 asset", () => {
@@ -80,9 +80,9 @@ describe("selectAsset", () => {
8080
expect(asset?.name).toBe("github-code-search-linux-arm64");
8181
});
8282

83-
it("selects win32-x64 asset with .exe suffix", () => {
83+
it("selects windows-x64 asset with .exe suffix for win32/x64", () => {
8484
const asset = selectAsset(assets, "win32", "x64");
85-
expect(asset?.name).toBe("github-code-search-win32-x64.exe");
85+
expect(asset?.name).toBe("github-code-search-windows-x64.exe");
8686
});
8787

8888
it("returns null when no matching asset is found", () => {

src/upgrade.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,22 @@ export function isNewerVersion(current: string, latest: string): boolean {
3838
/**
3939
* Picks the release asset matching the current platform and architecture.
4040
* Expected asset naming convention:
41-
* github-code-search-<platform>-<arch> (e.g. darwin-arm64)
41+
* github-code-search-<platform>-<arch> (e.g. macos-arm64)
4242
* github-code-search-<platform>-<arch>.exe (Windows)
43+
*
44+
* Node.js/Bun platform names are mapped to artifact names:
45+
* darwin → macos
46+
* win32 → windows
4347
*/
4448
export function selectAsset(
4549
assets: ReleaseAsset[],
4650
platform: string,
4751
arch: string,
4852
): ReleaseAsset | null {
49-
const suffix = platform === "win32" ? ".exe" : "";
50-
const name = `github-code-search-${platform}-${arch}${suffix}`;
53+
const platformMap: Record<string, string> = { darwin: "macos", win32: "windows" };
54+
const artifactPlatform = platformMap[platform] ?? platform;
55+
const suffix = artifactPlatform === "windows" ? ".exe" : "";
56+
const name = `github-code-search-${artifactPlatform}-${arch}${suffix}`;
5157
return assets.find((a) => a.name === name) ?? null;
5258
}
5359

0 commit comments

Comments
 (0)