Skip to content

Commit 5b83860

Browse files
committed
fix(nsis): move generated custom messages to separate files (to avoid stdin encoding issues on Windows)
Close #1447
1 parent 88e52ad commit 5b83860

File tree

6 files changed

+36
-21
lines changed

6 files changed

+36
-21
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"chromium-pickle-js": "^0.2.0",
3838
"cuint": "^0.2.2",
3939
"debug": "^2.6.3",
40-
"electron-download-tf": "4.1.1",
40+
"@electron-builder/electron-download": "4.2.1",
4141
"electron-osx-sign": "0.4.4",
4242
"fs-extra-p": "^4.1.0",
4343
"hosted-git-info": "^2.4.1",

packages/electron-builder/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"electron-builder-core": "0.0.0-semantic-release",
5555
"electron-builder-http": "0.0.0-semantic-release",
5656
"electron-builder-util": "0.0.0-semantic-release",
57-
"electron-download-tf": "4.1.1",
57+
"@electron-builder/electron-download": "4.2.1",
5858
"electron-osx-sign": "0.4.4",
5959
"electron-publish": "0.0.0-semantic-release",
6060
"fs-extra-p": "^4.1.0",

packages/electron-builder/src/packager/dirPackager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { chmod, emptyDir } from "fs-extra-p"
77
import * as path from "path"
88
import { PlatformPackager } from "../platformPackager"
99

10-
const downloadElectron: (options: any) => Promise<any> = BluebirdPromise.promisify(require("electron-download-tf"))
10+
const downloadElectron: (options: any) => Promise<any> = BluebirdPromise.promisify(require("@electron-builder/electron-download"))
1111

1212
function createDownloadOpts(opts: any, platform: string, arch: string, electronVersion: string) {
1313
if (opts.download != null) {

packages/electron-builder/src/targets/nsis.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { asArray, debug, doSpawn, exec, getPlatformIconFileName, handleProcess,
44
import { getBinFromBintray } from "electron-builder-util/out/binDownload"
55
import { copyFile } from "electron-builder-util/out/fs"
66
import { log, subTask, warn } from "electron-builder-util/out/log"
7-
import { readFile, unlink } from "fs-extra-p"
7+
import { outputFile, readFile, unlink } from "fs-extra-p"
88
import { safeLoad } from "js-yaml"
99
import * as path from "path"
1010
import sanitizeFileName from "sanitize-filename"
@@ -407,6 +407,12 @@ export class NsisTarget extends Target {
407407
})
408408
}
409409

410+
private async writeCustomLangFile(data: string) {
411+
const file = await this.packager.getTempFile("messages.nsh")
412+
await outputFile(file, data)
413+
return file
414+
}
415+
410416
private async computeFinalScript(originalScript: string, isInstaller: boolean) {
411417
const packager = this.packager
412418
let scriptHeader = `!addincludedir "${path.win32.join(__dirname, "..", "..", "templates", "nsis", "include")}"\n`
@@ -421,14 +427,18 @@ export class NsisTarget extends Target {
421427
scriptHeader += createMacro("licensePage", licensePage)
422428
}
423429

424-
scriptHeader += "\n" + computeCustomMessageTranslations(safeLoad(await readFile(path.join(this.nsisTemplatesDir, "messages.yml"), "utf-8"))).join("\n") + "\n\n"
430+
const addCustomMessageFileInclude = async (input: string) => {
431+
scriptHeader += "!include " + await this.writeCustomLangFile(computeCustomMessageTranslations(safeLoad(await readFile(path.join(this.nsisTemplatesDir, input), "utf-8"))).join("\n")) + "\n"
432+
}
433+
434+
await addCustomMessageFileInclude("messages.yml")
425435

426436
if (this.isPortable) {
427437
return scriptHeader + originalScript
428438
}
429439

430440
if (this.options.oneClick === false) {
431-
scriptHeader += "\n" + computeCustomMessageTranslations(safeLoad(await readFile(path.join(this.nsisTemplatesDir, "boringMessages.yml"), "utf-8"))).join("\n") + "\n\n"
441+
await addCustomMessageFileInclude("boringMessages.yml")
432442
}
433443

434444
const customInclude = await packager.getResource(this.options.include, "installer.nsh")

test/src/helpers/runTests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { ELECTRON_VERSION, TEST_DIR } from "./config"
99
const util = require("../../../packages/electron-builder-util/out/util")
1010
const isEmptyOrSpaces = util.isEmptyOrSpaces
1111

12-
const downloadElectron: (options: any) => Promise<any> = BluebirdPromise.promisify(require("electron-download-tf"))
12+
const downloadElectron: (options: any) => Promise<any> = BluebirdPromise.promisify(require("@electron-builder/electron-download"))
1313

1414
runTests()
1515
.catch(error => {

yarn.lock

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,20 @@
3131
typescript "~2.1.5"
3232
yargs "^7.0.2"
3333

34+
"@electron-builder/electron-download@4.2.1":
35+
version "4.2.1"
36+
resolved "https://registry.yarnpkg.com/@electron-builder/electron-download/-/electron-download-4.2.1.tgz#b10b7b077523ae2f6c21dc05658df145d716c223"
37+
dependencies:
38+
debug "^2.6.3"
39+
env-paths "^1.0.0"
40+
fs-extra "^2.1.2"
41+
minimist "^1.2.0"
42+
nugget "^2.0.1"
43+
path-exists "^3.0.0"
44+
rc "^1.2.1"
45+
semver "^5.3.0"
46+
sumchecker "^2.0.2"
47+
3448
"@types/electron@^1.4.35":
3549
version "1.4.35"
3650
resolved "https://registry.yarnpkg.com/@types/electron/-/electron-1.4.35.tgz#48e5e6ef0b49f27b9f78b87d80f796e3f0a4f33c"
@@ -1064,19 +1078,6 @@ ecc-jsbn@~0.1.1:
10641078
dependencies:
10651079
jsbn "~0.1.0"
10661080

1067-
electron-download-tf@4.1.1:
1068-
version "4.1.1"
1069-
resolved "https://registry.yarnpkg.com/electron-download-tf/-/electron-download-tf-4.1.1.tgz#127aaa6a10ccf598bc15ed6ae83390348ebb3b4b"
1070-
dependencies:
1071-
debug "^2.6.3"
1072-
fs-extra "^2.1.2"
1073-
minimist "^1.2.0"
1074-
nugget "^2.0.1"
1075-
path-exists "^3.0.0"
1076-
rc "^1.1.7"
1077-
semver "^5.3.0"
1078-
sumchecker "^2.0.2"
1079-
10801081
electron-osx-sign@0.4.4:
10811082
version "0.4.4"
10821083
resolved "https://registry.yarnpkg.com/electron-osx-sign/-/electron-osx-sign-0.4.4.tgz#afdf38450ccaebe6dabeca71fb0fad6294a8c57c"
@@ -1095,6 +1096,10 @@ end-of-stream@^1.0.0:
10951096
dependencies:
10961097
once "^1.4.0"
10971098

1099+
env-paths@^1.0.0:
1100+
version "1.0.0"
1101+
resolved "https://registry.yarnpkg.com/env-paths/-/env-paths-1.0.0.tgz#4168133b42bb05c38a35b1ae4397c8298ab369e0"
1102+
10981103
"errno@>=0.1.1 <0.2.0-0":
10991104
version "0.1.4"
11001105
resolved "https://registry.yarnpkg.com/errno/-/errno-0.1.4.tgz#b896e23a9e5e8ba33871fc996abd3635fc9a1c7d"
@@ -2612,7 +2617,7 @@ randomatic@^1.1.3:
26122617
is-number "^2.0.2"
26132618
kind-of "^3.0.2"
26142619

2615-
rc@^1.0.1, rc@^1.1.6, rc@^1.1.7:
2620+
rc@^1.0.1, rc@^1.1.6, rc@^1.2.1:
26162621
version "1.2.1"
26172622
resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.1.tgz#2e03e8e42ee450b8cb3dce65be1bf8974e1dfd95"
26182623
dependencies:

0 commit comments

Comments
 (0)