1
1
import * as fs from "fs"
2
2
import * as path from "path"
3
- import { DEFAULT_APP_DIR_NAME , installDependencies , log , getElectronVersion } from "./util"
4
- import { parseJsonFile } from "./promisifed-fs"
3
+ import { DEFAULT_APP_DIR_NAME , installDependencies , log , getElectronVersion , readPackageJson } from "./util"
5
4
import { all , executeFinally } from "./promise"
6
5
import { EventEmitter } from "events"
7
6
import { Promise as BluebirdPromise } from "bluebird"
@@ -52,22 +51,23 @@ export class Packager implements BuildInfo {
52
51
async build ( ) : Promise < any > {
53
52
const buildPackageFile = this . devPackageFile
54
53
const appPackageFile = this . projectDir === this . appDir ? buildPackageFile : path . join ( this . appDir , "package.json" )
55
- await BluebirdPromise . all ( Array . from ( new Set ( [ buildPackageFile , appPackageFile ] ) , parseJsonFile ) )
56
- . then ( ( result : any [ ] ) => {
54
+ const platforms = normalizePlatforms ( this . options . platform )
55
+ await BluebirdPromise . all ( Array . from ( new Set ( [ buildPackageFile , appPackageFile ] ) , readPackageJson ) )
56
+ . then ( result => {
57
57
this . metadata = result [ result . length - 1 ]
58
58
this . devMetadata = result [ 0 ]
59
- this . checkMetadata ( appPackageFile )
59
+ this . checkMetadata ( appPackageFile , platforms )
60
60
61
61
this . electronVersion = getElectronVersion ( this . devMetadata , buildPackageFile )
62
62
} )
63
63
64
64
const cleanupTasks : Array < ( ) => Promise < any > > = [ ]
65
- return executeFinally ( this . doBuild ( cleanupTasks ) , error => all ( cleanupTasks . map ( it => it ( ) ) ) )
65
+ return executeFinally ( this . doBuild ( platforms , cleanupTasks ) , error => all ( cleanupTasks . map ( it => it ( ) ) ) )
66
66
}
67
67
68
- private async doBuild ( cleanupTasks : Array < ( ) => Promise < any > > ) : Promise < any > {
68
+ private async doBuild ( platforms : Array < string > , cleanupTasks : Array < ( ) => Promise < any > > ) : Promise < any > {
69
69
const distTasks : Array < Promise < any > > = [ ]
70
- for ( let platform of normalizePlatforms ( this . options . platform ) ) {
70
+ for ( let platform of platforms ) {
71
71
const helper = this . createHelper ( platform , cleanupTasks )
72
72
const archs = platform === "darwin" ? [ "x64" ] : ( this . options . arch == null || this . options . arch === "all" ? [ "ia32" , "x64" ] : [ this . options . arch ] )
73
73
for ( let arch of archs ) {
@@ -136,7 +136,7 @@ export class Packager implements BuildInfo {
136
136
return absoluteAppPath
137
137
}
138
138
139
- private checkMetadata ( appPackageFile : string ) : void {
139
+ private checkMetadata ( appPackageFile : string , platforms : Array < string > ) : void {
140
140
const reportError = ( missedFieldName : string ) => {
141
141
throw new Error ( "Please specify '" + missedFieldName + "' in the application package.json ('" + appPackageFile + "')" )
142
142
}
@@ -154,8 +154,14 @@ export class Packager implements BuildInfo {
154
154
else if ( metadata . build == null ) {
155
155
throw new Error ( util . format ( errorMessages . buildIsMissed , appPackageFile ) )
156
156
}
157
- else if ( metadata . author == null ) {
158
- reportError ( "author" )
157
+ else {
158
+ const author = metadata . author
159
+ if ( author == null ) {
160
+ reportError ( "author" )
161
+ }
162
+ else if ( this . options . dist && author . email == null && platforms . includes ( "linux" ) ) {
163
+ throw new Error ( util . format ( errorMessages . authorEmailIsMissed , appPackageFile ) )
164
+ }
159
165
}
160
166
}
161
167
0 commit comments