@@ -5,9 +5,10 @@ import * as path from "path"
5
5
import { Promise as BluebirdPromise } from "bluebird"
6
6
import { getBin } from "../util/binDownload"
7
7
import { v5 as uuid5 } from "uuid-1345"
8
- import { getArchSuffix , Target } from "../platformPackager"
8
+ import { Target } from "../platformPackager"
9
9
import { archiveApp } from "./archive"
10
- import { subTask } from "../util/log"
10
+ import { subTask , task } from "../util/log"
11
+ import { unlink } from "fs-extra-p"
11
12
import sanitizeFileName = require( "sanitize-filename" )
12
13
import semver = require( "semver" )
13
14
@@ -26,22 +27,33 @@ const nsisPathPromise = getBin("nsis", NSIS_VERSION, `https://dl.bintray.com/ele
26
27
export default class NsisTarget extends Target {
27
28
private readonly options : NsisOptions
28
29
29
- constructor ( private packager : WinPackager ) {
30
+ private archs : Map < Arch , Promise < string > > = new Map ( )
31
+
32
+ constructor ( private packager : WinPackager , private outDir : string ) {
30
33
super ( "nsis" )
31
34
32
35
this . options = packager . info . devMetadata . build . nsis || Object . create ( null )
33
36
}
34
37
35
- async build ( arch : Arch , outDir : string , appOutDir : string ) {
38
+ async build ( arch : Arch , appOutDir : string ) {
39
+ const packager = this . packager
40
+ const archSuffix = arch == Arch . x64 ? "x64" : "ia32"
41
+ const archiveFile = path . join ( this . outDir , `${ packager . appInfo . name } -${ packager . appInfo . version } -${ archSuffix } .nsis.7z` )
42
+ this . archs . set ( arch , task ( `Creating NSIS ${ archSuffix } package` , archiveApp ( packager . devMetadata . build . compression , "7z" , archiveFile , appOutDir , true ) ) )
43
+ }
44
+
45
+ finishBuild ( ) : Promise < any > {
46
+ return task ( "Building NSIS installer" , this . buildInstaller ( )
47
+ . then ( ( ) => BluebirdPromise . map ( this . archs . values ( ) , it => unlink ( it ) ) ) )
48
+ }
49
+
50
+ private async buildInstaller ( ) : Promise < any > {
36
51
const packager = this . packager
37
52
38
53
const iconPath = await packager . getIconPath ( )
39
54
const appInfo = packager . appInfo
40
55
const version = appInfo . version
41
- const archSuffix = getArchSuffix ( arch )
42
- const installerPath = path . join ( outDir , `${ appInfo . productName } Setup ${ version } ${ archSuffix } .exe` )
43
- // const archiveFile = path.join(this.outDir, `.${packager.metadata.name}-${packager.metadata.version}${archSuffix}.7z`)
44
- const archiveFile = path . join ( outDir , `app.7z` )
56
+ const installerPath = path . join ( this . outDir , `${ appInfo . productName } Setup ${ version } .exe` )
45
57
46
58
const guid = this . options . guid || await BluebirdPromise . promisify ( uuid5 ) ( { namespace : ELECTRON_BUILDER_NS_UUID , name : appInfo . id } )
47
59
const productName = appInfo . productName
@@ -51,7 +63,6 @@ export default class NsisTarget extends Target {
51
63
PRODUCT_NAME : productName ,
52
64
INST_DIR_NAME : sanitizeFileName ( productName ) ,
53
65
APP_DESCRIPTION : appInfo . description ,
54
- APP_ARCHIVE : archiveFile ,
55
66
VERSION : version ,
56
67
57
68
MUI_ICON : iconPath ,
@@ -60,6 +71,10 @@ export default class NsisTarget extends Target {
60
71
COMPANY_NAME : appInfo . companyName ,
61
72
}
62
73
74
+ for ( let [ arch , file ] of this . archs ) {
75
+ defines [ arch === Arch . x64 ? "APP_64" : "APP_32" ] = await file
76
+ }
77
+
63
78
let installerHeader = this . options . installerHeader
64
79
if ( installerHeader === undefined ) {
65
80
const resourceList = await packager . resourceList
@@ -117,8 +132,6 @@ export default class NsisTarget extends Target {
117
132
defines . COMPRESS = "auto"
118
133
}
119
134
120
- await subTask ( "Packing app into 7z archive" , archiveApp ( packager . devMetadata . build . compression , "7z" , archiveFile , appOutDir , true ) )
121
-
122
135
const oneClick = this . options . oneClick !== false
123
136
if ( oneClick ) {
124
137
defines . ONE_CLICK = null
@@ -134,7 +147,7 @@ export default class NsisTarget extends Target {
134
147
await subTask ( `Executing makensis` , NsisTarget . executeMakensis ( defines , commands ) )
135
148
await packager . sign ( installerPath )
136
149
137
- this . packager . dispatchArtifactCreated ( installerPath , `${ appInfo . name } -Setup-${ version } ${ archSuffix } .exe` )
150
+ this . packager . dispatchArtifactCreated ( installerPath , `${ appInfo . name } -Setup-${ version } .exe` )
138
151
}
139
152
140
153
private static async executeMakensis ( defines : any , commands : any ) {
0 commit comments