Skip to content

Commit 94677f3

Browse files
authored
fix(mac): merge fileAssociations with existing CFBundleDocumentTypes if defined in mac.extendInfo (#8035)
1 parent 6fec9e8 commit 94677f3

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

.changeset/fifty-lions-burn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"app-builder-lib": patch
3+
---
4+
5+
fix(mac): merge `fileAssociations` with existing `CFBundleDocumentTypes` if defined in `mac.extendInfo`

packages/app-builder-lib/src/electron/electronMac.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ export async function createMacApp(packager: MacPackager, appOutDir: string, asa
201201

202202
const fileAssociations = packager.fileAssociations
203203
if (fileAssociations.length > 0) {
204-
appPlist.CFBundleDocumentTypes = await BluebirdPromise.map(fileAssociations, async fileAssociation => {
204+
const documentTypes = await BluebirdPromise.map(fileAssociations, async fileAssociation => {
205205
const extensions = asArray(fileAssociation.ext).map(normalizeExt)
206206
const customIcon = await packager.getResource(getPlatformIconFileName(fileAssociation.icon, true), `${extensions[0]}.icns`)
207207
let iconFile = appPlist.CFBundleIconFile
@@ -223,6 +223,9 @@ export async function createMacApp(packager: MacPackager, appOutDir: string, asa
223223
}
224224
return result
225225
})
226+
227+
// `CFBundleDocumentTypes` may be defined in `mac.extendInfo`, so we need to merge it in that case
228+
appPlist.CFBundleDocumentTypes = [...(appPlist.CFBundleDocumentTypes || []), ...documentTypes]
226229
}
227230

228231
if (asarIntegrity != null) {

test/snapshots/mac/macPackagerTest.js.snap

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ exports[`one-package 2`] = `
6868
Object {
6969
"CFBundleDisplayName": "Test App ßW",
7070
"CFBundleDocumentTypes": Array [
71+
Object {
72+
"CFBundleTypeName": "Folders",
73+
"CFBundleTypeRole": "Editor",
74+
"LSItemContentTypes": Array [
75+
"public.folder",
76+
],
77+
},
7178
Object {
7279
"CFBundleTypeExtensions": Array [
7380
"foo",

test/src/mac/macPackagerTest.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ test.ifMac(
5454
appId: "foo",
5555
extendInfo: {
5656
LSUIElement: true,
57+
CFBundleDocumentTypes: [
58+
{
59+
CFBundleTypeName: "Folders",
60+
CFBundleTypeRole: "Editor",
61+
LSItemContentTypes: ["public.folder"],
62+
},
63+
],
5764
},
5865
minimumSystemVersion: "10.12.0",
5966
fileAssociations: [

0 commit comments

Comments
 (0)