Skip to content

Commit

Permalink
fix: win32 asset matching pattern (#175)
Browse files Browse the repository at this point in the history
* refactor: win32 asset matching pattern

Signed-off-by: Adam Setch <[email protected]>

* refactor: win32 asset matching pattern

Signed-off-by: Adam Setch <[email protected]>

---------

Signed-off-by: Adam Setch <[email protected]>
  • Loading branch information
setchy authored Jan 3, 2025
1 parent e8cdb9d commit a69a327
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/asset-platform.js
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

0 comments on commit a69a327

Please sign in to comment.