@@ -126,20 +126,22 @@ export class Packager implements BuildInfo {
126
126
127
127
private checkMetadata ( appPackageFile : string , devAppPackageFile : string , platforms : Array < Platform > ) : void {
128
128
const reportError = ( missedFieldName : string ) => {
129
- throw new Error ( " Please specify '" + missedFieldName + " ' in the application package.json ('" + appPackageFile + "')" )
129
+ throw new Error ( ` Please specify '${ missedFieldName } ' in the application package.json ('${ appPackageFile } ')` )
130
130
}
131
131
132
- const appMetadata = this . metadata
133
- if ( < any > appMetadata . name == null ) {
134
- reportError ( "name" )
135
- }
136
- else if ( < any > appMetadata . description == null ) {
137
- reportError ( "description" )
138
- }
139
- else if ( < any > appMetadata . version == null ) {
140
- reportError ( "version" )
132
+ const checkNotEmpty = ( name : string , value : string ) => {
133
+ if ( isEmptyOrSpaces ( value ) ) {
134
+ reportError ( name )
135
+ }
141
136
}
142
- else if ( ( < any > appMetadata ) !== this . devMetadata ) {
137
+
138
+ const appMetadata = this . metadata
139
+
140
+ checkNotEmpty ( "name" , appMetadata . name )
141
+ checkNotEmpty ( "description" , appMetadata . description )
142
+ checkNotEmpty ( "version" , appMetadata . version )
143
+
144
+ if ( ( < any > appMetadata ) !== this . devMetadata ) {
143
145
if ( ( < any > appMetadata ) . build != null ) {
144
146
throw new Error ( util . format ( errorMessages . buildInAppSpecified , appPackageFile , devAppPackageFile ) )
145
147
}
@@ -251,4 +253,8 @@ async function checkWineVersion(checkPromise: Promise<Buffer[]>) {
251
253
if ( compareVersions ( wineVersion , "1.8" ) === - 1 ) {
252
254
throw new Error ( wineError ( `wine 1.8+ is required, but your version is ${ wineVersion } ` ) )
253
255
}
256
+ }
257
+
258
+ function isEmptyOrSpaces ( s : string | n ) {
259
+ return s == null || s . trim ( ) . length === 0
254
260
}
0 commit comments