@@ -7,14 +7,21 @@ const path = require('path')
77const fs = require ( 'fs' )
88
99const config = {
10- arch : 'x64' ,
11- asar : true ,
12- dir : where . app ,
13- icon : path . join ( where . app , 'assets/images/app-icon' ) ,
14- ignore : 'editor/' ,
15- out : path . join ( where . root , 'builds' ) ,
16- overwrite : true ,
17- platform : [ 'darwin' , 'linux' , 'win32' ]
10+ packager : {
11+ arch : 'x64' ,
12+ asar : true ,
13+ dir : where . app ,
14+ icon : path . join ( where . app , 'assets/images/app-icon' ) ,
15+ ignore : 'editor/' ,
16+ out : path . join ( where . root , 'builds' ) ,
17+ overwrite : true ,
18+ platform : [ 'darwin' , 'linux' , 'win32' ]
19+ } ,
20+ packageName : {
21+ 'Thinreports Editor-darwin-x64' : 'ThinreportsEditor-mac' ,
22+ 'Thinreports Editor-linux-x64' : 'ThinreportsEditor-linux' ,
23+ 'Thinreports Editor-win32-x64' : 'ThinreportsEditor-windows'
24+ }
1825}
1926
2027clean ( )
@@ -28,7 +35,8 @@ function clean () {
2835function build ( ) {
2936 console . log ( '\x1b[34mBuilding electron app(s)...\n\x1b[0m' )
3037
31- packager ( config )
38+ packager ( config . packager )
39+ . then ( mapPackageNameAll )
3240 . then ( archiveAll )
3341 . then ( ( appPaths ) => {
3442 console . log ( 'Build(s) successful!' )
@@ -40,6 +48,31 @@ function build () {
4048 } )
4149}
4250
51+ function mapPackageNameAll ( appPaths ) {
52+ return Promise . all ( appPaths . map ( mapPackageName ) )
53+ }
54+
55+ function mapPackageName ( appPath ) {
56+ return new Promise ( ( resolve , reject ) => {
57+ const originalName = path . basename ( appPath )
58+ const mappedName = config . packageName [ originalName ]
59+
60+ if ( ! mappedName ) {
61+ reject ( `No package name setting for #{originalName}` )
62+ }
63+
64+ const mappedAppPath = path . join ( path . dirname ( appPath ) , mappedName )
65+
66+ fs . rename ( appPath , mappedAppPath , error => {
67+ if ( error ) {
68+ reject ( error )
69+ } else {
70+ resolve ( mappedAppPath )
71+ }
72+ } )
73+ } )
74+ }
75+
4376function archiveAll ( appPaths ) {
4477 return Promise . all ( appPaths . map ( archive ) )
4578}
0 commit comments