Skip to content

Commit 0476c06

Browse files
committed
fix: support latest electron builder default macOS release names
Signed-off-by: Adam Setch <[email protected]>
1 parent 3638132 commit 0476c06

File tree

4 files changed

+35
-9
lines changed

4 files changed

+35
-9
lines changed

src/asset-platform.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
const { PLATFORM_ARCH } = require("./constants");
22

33
const assetPlatform = (fileName) => {
4-
if (/.*(mac|darwin|osx).*(-arm).*\.zip/i.test(fileName)) {
5-
return PLATFORM_ARCH.DARWIN_ARM64;
6-
}
7-
8-
if (/.*(mac|darwin|osx).*\.zip/i.test(fileName) && !/arm64/.test(fileName)) {
4+
if (/.*(mac|darwin|osx).*\.zip/i.test(fileName)) {
5+
if (/universal/.test(fileName)) return PLATFORM_ARCH.DARWIN_UNIVERSAL;
6+
if (/arm64/.test(fileName)) return PLATFORM_ARCH.DARWIN_ARM64;
97
return PLATFORM_ARCH.DARWIN_X64;
108
}
119

src/updates.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,27 @@ class Updates {
9595
}
9696

9797
async handleUpdate(res, account, repository, platform, version) {
98-
const latest = await this.cachedGetLatest(
98+
let latest = await this.cachedGetLatest(
9999
account,
100100
repository,
101101
platform,
102102
version
103103
);
104104

105+
const latestUniversal = await this.cachedGetLatest(
106+
account,
107+
repository,
108+
PLATFORM_ARCH.DARWIN_UNIVERSAL,
109+
version
110+
);
111+
112+
if (!latest && latestUniversal) {
113+
latest = latestUniversal;
114+
}
115+
105116
if (!latest) {
106117
const message = platform.includes(PLATFORM.DARWIN)
107-
? "No updates found (needs asset matching *(mac|darwin|osx).*(-arm).*.zip in public repository)"
118+
? "No updates found (needs asset matching *(mac|darwin|osx).*.zip in public repository)"
108119
: "No updates found (needs asset containing win32-{x64,ia32,arm64} or .exe in public repository)";
109120
notFound(res, message);
110121
} else if (semver.lte(latest.version, version)) {

test/asset-platform.test.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,27 @@ test("assetPlatform() matches the right platform", (t) => {
2828
name: "Electron.Fiddle-darwin-arm64-0.27.3.zip",
2929
platform: PLATFORM_ARCH.DARWIN_ARM64,
3030
},
31+
{
32+
name: "Electron.Fiddle-0.27.3-arm64-mac.zip",
33+
platform: PLATFORM_ARCH.DARWIN_ARM64,
34+
},
3135
{
3236
name: "Electron.Fiddle-darwin-x64-0.27.3.zip",
3337
platform: PLATFORM_ARCH.DARWIN_X64,
3438
},
39+
// Electron Builder
40+
{
41+
name: "Electron-Builder-1.2.3-mac.zip",
42+
platform: PLATFORM_ARCH.DARWIN_X64,
43+
},
44+
{
45+
name: "Electron-Builder-1.2.3-universal-mac.zip",
46+
platform: PLATFORM_ARCH.DARWIN_UNIVERSAL,
47+
},
48+
{
49+
name: "Electron-Builder-1.2.3-arm64-mac.zip",
50+
platform: PLATFORM_ARCH.DARWIN_ARM64,
51+
},
3552
];
3653

3754
for (const release of releases) {

test/update.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,15 +346,15 @@ test("Updates", async (t) => {
346346
let body = await res.text();
347347
t.equal(
348348
body,
349-
"No updates found (needs asset matching *(mac|darwin|osx).*(-arm).*.zip in public repository)"
349+
"No updates found (needs asset matching *(mac|darwin|osx).*.zip in public repository)"
350350
);
351351

352352
res = await fetch(`${address}/owner/repo-win32-zip/darwin/0.0.0`);
353353
t.equal(res.status, 404);
354354
body = await res.text();
355355
t.equal(
356356
body,
357-
"No updates found (needs asset matching *(mac|darwin|osx).*(-arm).*.zip in public repository)"
357+
"No updates found (needs asset matching *(mac|darwin|osx).*.zip in public repository)"
358358
);
359359
});
360360
});

0 commit comments

Comments
 (0)