Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(mac): merge fileAssociations with existing CFBundleDocumentTypes if defined in mac.extendInfo #8035

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fifty-lions-burn.md
@@ -0,0 +1,5 @@
---
"app-builder-lib": patch
---

fix(mac): merge `fileAssociations` with existing `CFBundleDocumentTypes` if defined in `mac.extendInfo`
5 changes: 4 additions & 1 deletion packages/app-builder-lib/src/electron/electronMac.ts
Expand Up @@ -201,7 +201,7 @@ export async function createMacApp(packager: MacPackager, appOutDir: string, asa

const fileAssociations = packager.fileAssociations
if (fileAssociations.length > 0) {
appPlist.CFBundleDocumentTypes = await BluebirdPromise.map(fileAssociations, async fileAssociation => {
const documentTypes = await BluebirdPromise.map(fileAssociations, async fileAssociation => {
const extensions = asArray(fileAssociation.ext).map(normalizeExt)
const customIcon = await packager.getResource(getPlatformIconFileName(fileAssociation.icon, true), `${extensions[0]}.icns`)
let iconFile = appPlist.CFBundleIconFile
Expand All @@ -223,6 +223,9 @@ export async function createMacApp(packager: MacPackager, appOutDir: string, asa
}
return result
})

// `CFBundleDocumentTypes` may be defined in `mac.extendInfo`, so we need to merge it in that case
appPlist.CFBundleDocumentTypes = [...(appPlist.CFBundleDocumentTypes || []), ...documentTypes]
mmaietta marked this conversation as resolved.
Show resolved Hide resolved
}

if (asarIntegrity != null) {
Expand Down
7 changes: 7 additions & 0 deletions test/snapshots/mac/macPackagerTest.js.snap
Expand Up @@ -68,6 +68,13 @@ exports[`one-package 2`] = `
Object {
"CFBundleDisplayName": "Test App ßW",
"CFBundleDocumentTypes": Array [
Object {
"CFBundleTypeName": "Folders",
"CFBundleTypeRole": "Editor",
"LSItemContentTypes": Array [
"public.folder",
],
},
Object {
"CFBundleTypeExtensions": Array [
"foo",
Expand Down
7 changes: 7 additions & 0 deletions test/src/mac/macPackagerTest.ts
Expand Up @@ -54,6 +54,13 @@ test.ifMac(
appId: "foo",
extendInfo: {
LSUIElement: true,
CFBundleDocumentTypes: [
{
CFBundleTypeName: "Folders",
CFBundleTypeRole: "Editor",
LSItemContentTypes: ["public.folder"],
},
],
},
minimumSystemVersion: "10.12.0",
fileAssociations: [
Expand Down