Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix(mac): accept an object-form publish config in afterPack

EtienneLescot633e9fc4c64b
diff --git a/scripts/after-pack.cjs b/scripts/after-pack.cjs
index a31834549..557f3db2f 100644
--- a/scripts/after-pack.cjs
+++ b/scripts/after-pack.cjs
@@ -27,7 +27,7 @@ exports.default = async function afterPack(context) {
const { packager } = context;
const file = path.join(packager.getResourcesDir(context.appOutDir), "app-update.yml");
if (fs.existsSync(file)) return;
- const [publish] = packager.config.publish ?? [];
+ const [publish] = [packager.config.publish ?? []].flat();
if (publish == null) throw new Error("afterPack: no publish config to write app-update.yml from");
fs.writeFileSync(file, appUpdateYaml(publish, packager.appInfo.updaterCacheDirName));
console.log(` • wrote ${path.relative(context.appOutDir, file)}`);
diff --git a/scripts/after-pack.test.mjs b/scripts/after-pack.test.mjs
index 50a5b9e25..c3c79d87c 100644
--- a/scripts/after-pack.test.mjs
+++ b/scripts/after-pack.test.mjs
@@ -51,6 +51,13 @@ describe("afterPack app-update.yml", () => {
expect(fs.readFileSync(ctx.file, "utf8")).toBe("provider: generic\n");
});
+ it("accepts a single publish object as well as an array", async () => {
+ const ctx = context("darwin");
+ ctx.packager.config.publish = ctx.packager.config.publish[0];
+ await afterPack(ctx);
+ expect(fs.readFileSync(ctx.file, "utf8")).toMatch(/^provider: github\n/);
+ });
+
it("writes nothing on Windows or Linux", async () => {
for (const platform of ["win32", "linux"]) {
const ctx = context(platform);