Skip to content

Commit e5d58e2

Browse files
committed
fix(electron-updater): Autoupdater problem on mac if space in the URL
Close #1192
1 parent a2f64bb commit e5d58e2

File tree

5 files changed

+22
-6
lines changed

5 files changed

+22
-6
lines changed

.idea/codeStyleSettings.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/electron-builder/src/publish/PublishManager.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ export class PublishManager {
5151

5252
if (publishOptions.publish != null && publishOptions.publish !== "never") {
5353
this.isPublish = publishOptions.publish !== "onTag" || getCiTag() != null
54-
if (this.isPublish && !isAuthTokenSet()) {
55-
throw new Error(`Publish is set to ${publishOptions.publish}, but neither GH_TOKEN nor BT_TOKEN is not set`)
56-
}
5754
}
5855
}
56+
else if (publishOptions.publish !== "never") {
57+
log("Current build is a part of pull request, publishing will be skipped")
58+
}
5959

6060
packager.addAfterPackHandler(async event => {
6161
if (!(event.electronPlatformName == "darwin" || event.packager.platform === Platform.WINDOWS)) {
@@ -264,11 +264,11 @@ function isAuthTokenSet() {
264264
function computeDownloadUrl(publishConfig: PublishConfiguration, fileName: string, version: string) {
265265
if (publishConfig.provider === "generic") {
266266
const baseUrl = url.parse((<GenericServerOptions>publishConfig).url)
267-
return url.format(Object.assign({}, baseUrl, {pathname: path.posix.resolve(baseUrl.pathname || "/", fileName)}))
267+
return url.format(Object.assign({}, baseUrl, {pathname: path.posix.resolve(baseUrl.pathname || "/", encodeURI(fileName))}))
268268
}
269269
else {
270270
const gh = <GithubOptions>publishConfig
271-
return `https://github.com${`/${gh.owner}/${gh.repo}/releases`}/download/v${version}/${fileName}`
271+
return `https://github.com${`/${gh.owner}/${gh.repo}/releases`}/download/v${version}/${encodeURI(fileName)}`
272272
}
273273
}
274274

test/out/mac/__snapshots__/macPackagerTest.js.snap

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ Array [
5757
]
5858
`;
5959

60+
exports[`test one-package 3`] = `
61+
Object {
62+
"url": "https://develar.s3.amazonaws.com/test/Test%20App%20%C3%9FW-1.1.0-mac.zip",
63+
"version": "1.1.0",
64+
}
65+
`;
66+
6067
exports[`test two-package 1`] = `
6168
Array [
6269
Object {

test/src/mac/macPackagerTest.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { assertPack, platform, app, appThrows } from "../helpers/packTester"
22
import { Platform, createTargets } from "electron-builder"
3+
import { readJson } from "fs-extra-p"
34
import { DIR_TARGET } from "electron-builder/out/targets/targetFactory"
45
import { copyFile } from "electron-builder-util/out/fs"
56
import * as path from "path"
@@ -10,6 +11,10 @@ test.ifMac("two-package", () => assertPack("test-app", {targets: createTargets([
1011
test.ifMac("one-package", app({
1112
targets: Platform.MAC.createTarget(),
1213
config: {
14+
publish: {
15+
provider: "generic",
16+
url: "https://develar.s3.amazonaws.com/test",
17+
},
1318
mac: {
1419
fileAssociations: [
1520
{
@@ -33,6 +38,9 @@ test.ifMac("one-package", app({
3338
expect(info).toMatchSnapshot()
3439
await assertThat(path.join(appDir, "Contents", "Resources", "foo.icns")).isFile()
3540
},
41+
packed: async context => {
42+
expect(await readJson(path.join(context.outDir, "latest-mac.json"))).toMatchSnapshot()
43+
},
3644
}))
3745

3846
test.ifMac("electronDist", appThrows(/ENOENT: no such file or directory/, {

test/src/nsisUpdaterTest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ test("file url generic", async () => {
8686
expect(actualEvents).toMatchSnapshot()
8787
})
8888

89-
test("sha2 mismatch error event", async () => {
89+
test.ifNotCiWin("sha2 mismatch error event", async () => {
9090
const updater = new NsisUpdater()
9191
updater.updateConfigPath = await writeUpdateConfig(<GenericServerOptions>{
9292
provider: "generic",

0 commit comments

Comments
 (0)