@@ -154,8 +154,17 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>
154
154
155
155
abstract pack ( outDir : string , arch : Arch , targets : Array < Target > , postAsyncTasks : Array < Promise < any > > ) : Promise < any >
156
156
157
+ private getExtraFilePatterns ( isResources : boolean , arch : Arch , customBuildOptions : DC ) : Array < Minimatch > | null {
158
+ const patterns = this . getFilePatterns ( isResources ? "extraResources" : "extraFiles" , customBuildOptions )
159
+ return patterns == null || patterns . length === 0 ? null : this . getParsedPatterns ( patterns , arch )
160
+ }
161
+
157
162
protected async doPack ( options : ElectronPackagerOptions , outDir : string , appOutDir : string , platformName : string , arch : Arch , platformSpecificBuildOptions : DC ) {
158
163
const asarOptions = this . computeAsarOptions ( platformSpecificBuildOptions )
164
+
165
+ const extraResourcePatterns = this . getExtraFilePatterns ( true , arch , platformSpecificBuildOptions )
166
+ const extraFilePatterns = this . getExtraFilePatterns ( false , arch , platformSpecificBuildOptions )
167
+
159
168
const p = pack ( options , appOutDir , platformName , Arch [ arch ] , this . info . electronVersion , async ( ) => {
160
169
const ignoreFiles = new Set ( [ path . relative ( this . info . appDir , outDir ) , path . relative ( this . info . appDir , this . buildResourcesDir ) ] )
161
170
if ( ! this . info . isTwoPackageJsonProjectLayoutUsed ) {
@@ -196,8 +205,24 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>
196
205
rawFilter = deprecatedUserIgnoreFilter ( options , this . info . appDir )
197
206
}
198
207
208
+ const filePatterns = this . getParsedPatterns ( patterns , arch )
209
+ let excludePatterns : Array < Minimatch > | null = null
210
+ if ( ! this . info . isTwoPackageJsonProjectLayoutUsed ) {
211
+ if ( extraResourcePatterns != null ) {
212
+ excludePatterns = extraResourcePatterns
213
+ }
214
+ if ( extraFilePatterns != null ) {
215
+ if ( excludePatterns == null ) {
216
+ excludePatterns = extraFilePatterns
217
+ }
218
+ else {
219
+ excludePatterns = excludePatterns . concat ( extraFilePatterns )
220
+ }
221
+ }
222
+ }
223
+
199
224
const resourcesPath = this . platform === Platform . MAC ? path . join ( appOutDir , "Electron.app" , "Contents" , "Resources" ) : path . join ( appOutDir , "resources" )
200
- const filter = createFilter ( this . info . appDir , this . getParsedPatterns ( patterns , arch ) , ignoreFiles , rawFilter )
225
+ const filter = createFilter ( this . info . appDir , filePatterns , ignoreFiles , rawFilter , excludePatterns )
201
226
const promise = asarOptions == null ?
202
227
copyFiltered ( this . info . appDir , path . join ( resourcesPath , "app" ) , filter , this . platform === Platform . WINDOWS )
203
228
: createAsarArchive ( this . info . appDir , resourcesPath , asarOptions , filter )
@@ -289,8 +314,8 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>
289
314
290
315
private async doCopyExtraFiles ( isResources : boolean , appOutDir : string , arch : Arch , customBuildOptions : DC ) : Promise < any > {
291
316
const base = isResources ? this . getResourcesDir ( appOutDir ) : this . platform === Platform . MAC ? path . join ( appOutDir , `${ this . appInfo . productFilename } .app` , "Contents" ) : appOutDir
292
- const patterns = this . getFilePatterns ( isResources ? "extraResources" : "extraFiles" , customBuildOptions )
293
- return patterns == null || patterns . length === 0 ? null : copyFiltered ( this . projectDir , base , createFilter ( this . projectDir , this . getParsedPatterns ( patterns , arch ) ) , this . platform === Platform . WINDOWS )
317
+ const patterns = this . getExtraFilePatterns ( isResources , arch , customBuildOptions )
318
+ return patterns == null || patterns . length === 0 ? null : copyFiltered ( this . projectDir , base , createFilter ( this . projectDir , patterns ) , this . platform === Platform . WINDOWS )
294
319
}
295
320
296
321
private getParsedPatterns ( patterns : Array < string > , arch : Arch ) : Array < Minimatch > {
0 commit comments