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

fix: win32 asset matching pattern #175

Merged
merged 3 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
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
9 changes: 6 additions & 3 deletions src/asset-platform.js

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the logic for this change?

Why not use an if-else ladder instead?

Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ const assetPlatform = (fileName) => {
return PLATFORM_ARCH.DARWIN_X64;
}

if (/win32-ia32/.test(fileName)) return PLATFORM_ARCH.WIN_IA32;
if (/win32-x64/.test(fileName)) return PLATFORM_ARCH.WIN_X64;
if (/win32-arm64/.test(fileName)) return PLATFORM_ARCH.WIN_ARM64;
if (/.*-win32-(ia32|x64|arm64).*$/i.test(fileName)) {
if (/-ia32/.test(fileName)) return PLATFORM_ARCH.WIN_IA32;
if (/-arm64/.test(fileName)) return PLATFORM_ARCH.WIN_ARM64;

return PLATFORM_ARCH.WIN_X64;
}

// Special case handling: We don't know what kind of asset
// we're looking at, so it might be the default x64 windows
Expand Down
2 changes: 1 addition & 1 deletion src/updates.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class Updates {
if (!latest) {
const message = platform.includes(PLATFORM.DARWIN)
? "No updates found (needs asset matching .*-(mac|darwin|osx).*.zip in public repository)"
: "No updates found (needs asset containing win32-{x64,ia32,arm64} or .exe in public repository)";
: "No updates found (needs asset containing .*-win32-(x64|ia32|arm64) or .exe in public repository)";
notFound(res, message);
} else if (semver.lte(latest.version, version)) {
log.debug({ account, repository, platform, version }, "up to date");
Expand Down
12 changes: 12 additions & 0 deletions test/asset-platform.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ test("assetPlatform() matches the right platform", (t) => {
name: "electron-fiddle-0.27.3-win32-x64-setup.exe",
platform: PLATFORM_ARCH.WIN_X64,
},
{
name: "win32.exe",
platform: PLATFORM_ARCH.WIN_X64,
},
{
name: "win32-arm64.exe",
platform: false,
},
{
name: "win32-ia32.exe",
platform: false,
},
{ name: "electron-fiddle_0.27.3_amd64.deb", platform: false },
{ name: "electron-fiddle_0.27.3_arm64.deb", platform: false },
{ name: "electron-fiddle_0.27.3_armhf.deb", platform: false },
Expand Down
2 changes: 1 addition & 1 deletion test/update.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ test("Updates", async (t) => {
const body = await res.text();
t.equal(
body,
"No updates found (needs asset containing win32-{x64,ia32,arm64} or .exe in public repository)"
"No updates found (needs asset containing .*-win32-(x64|ia32|arm64) or .exe in public repository)"
);
});
});
Expand Down