@@ -4,7 +4,7 @@ import { asArray, debug, doSpawn, exec, getPlatformIconFileName, handleProcess,
4
4
import { getBinFromBintray } from "electron-builder-util/out/binDownload"
5
5
import { copyFile } from "electron-builder-util/out/fs"
6
6
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"
8
8
import { safeLoad } from "js-yaml"
9
9
import * as path from "path"
10
10
import sanitizeFileName from "sanitize-filename"
@@ -407,6 +407,12 @@ export class NsisTarget extends Target {
407
407
} )
408
408
}
409
409
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
+
410
416
private async computeFinalScript ( originalScript : string , isInstaller : boolean ) {
411
417
const packager = this . packager
412
418
let scriptHeader = `!addincludedir "${ path . win32 . join ( __dirname , ".." , ".." , "templates" , "nsis" , "include" ) } "\n`
@@ -421,14 +427,18 @@ export class NsisTarget extends Target {
421
427
scriptHeader += createMacro ( "licensePage" , licensePage )
422
428
}
423
429
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" )
425
435
426
436
if ( this . isPortable ) {
427
437
return scriptHeader + originalScript
428
438
}
429
439
430
440
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" )
432
442
}
433
443
434
444
const customInclude = await packager . getResource ( this . options . include , "installer.nsh" )
0 commit comments