Skip to content

Commit

Permalink
feat(appx): added missing support for AppX fileAssociations (#4302)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielweck authored and develar committed Oct 22, 2019
1 parent 5692281 commit b16a890
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion packages/app-builder-lib/src/targets/AppxTarget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,16 @@ export default class AppXTarget extends Target {
const uriSchemes = asArray(this.packager.config.protocols)
.concat(asArray(this.packager.platformSpecificBuildOptions.protocols))

const fileAssociations = asArray(this.packager.config.fileAssociations)
.concat(asArray(this.packager.platformSpecificBuildOptions.fileAssociations))

let isAddAutoLaunchExtension = this.options.addAutoLaunchExtension
if (isAddAutoLaunchExtension === undefined) {
const deps = this.packager.info.metadata.dependencies
isAddAutoLaunchExtension = deps != null && deps["electron-winstore-auto-launch"] != null
}

if (!isAddAutoLaunchExtension && uriSchemes.length === 0) {
if (!isAddAutoLaunchExtension && uriSchemes.length === 0 && fileAssociations.length === 0) {
return ""
}

Expand All @@ -281,6 +284,19 @@ export default class AppXTarget extends Target {
}
}

for (const fileAssociation of fileAssociations) {
for (const ext of asArray(fileAssociation.ext)) {
extensions += `
<uap:Extension Category="windows.fileTypeAssociation">
<uap:FileTypeAssociation Name="${ext}">
<uap:SupportedFileTypes>
<uap:FileType>.${ext}</uap:FileType>
</uap:SupportedFileTypes>
</uap:FileTypeAssociation>
</uap:Extension>`
}
}

extensions += "</Extensions>"
return extensions
}
Expand Down

0 comments on commit b16a890

Please sign in to comment.