diff --git a/docs/Options.md b/docs/Options.md
index d1c4c2ae73d..685ae62eb7c 100644
--- a/docs/Options.md
+++ b/docs/Options.md
@@ -110,7 +110,7 @@ macOS (corresponds to [CFBundleDocumentTypes](https://developer.apple.com/librar
| Name | Description
| --- | ---
| **ext** | The extension (minus the leading period). e.g. `png`.
-| **name** | The name. e.g. `PNG`.
+| name | The name. e.g. `PNG`. Defaults to `ext`.
| description | *windows-only.* The description.
| icon | The path to icon (`.icns` for MacOS and `.ico` for Windows), relative to `build` (build resources directory). Defaults to `${firstExt}.icns`/`${firstExt}.ico` (if several extensions specified, first is used) or to application icon.
| role | *macOS-only* The app’s role with respect to the type. The value can be `Editor`, `Viewer`, `Shell`, or `None`. Defaults to `Editor`. Corresponds to `CFBundleTypeRole`.
diff --git a/packages/electron-builder/src/metadata.ts b/packages/electron-builder/src/metadata.ts
index 0ceef0847c0..a7e37b69af1 100755
--- a/packages/electron-builder/src/metadata.ts
+++ b/packages/electron-builder/src/metadata.ts
@@ -237,14 +237,14 @@ export interface FileAssociation {
readonly ext: string | Array
/*
- The name. e.g. `PNG`.
+ The name. e.g. `PNG`. Defaults to `ext`.
*/
- readonly name: string
+ readonly name?: string | null
/*
*windows-only.* The description.
*/
- readonly description?: string
+ readonly description?: string | null
/*
The path to icon (`.icns` for MacOS and `.ico` for Windows), relative to `build` (build resources directory). Defaults to `${firstExt}.icns`/`${firstExt}.ico` (if several extensions specified, first is used) or to application icon.
diff --git a/packages/electron-builder/src/packager/mac.ts b/packages/electron-builder/src/packager/mac.ts
index e97adacb6d1..175f75e8e7b 100644
--- a/packages/electron-builder/src/packager/mac.ts
+++ b/packages/electron-builder/src/packager/mac.ts
@@ -113,7 +113,7 @@ export async function createApp(packager: PlatformPackager, appOutDir: stri
const result = {
CFBundleTypeExtensions: extensions,
- CFBundleTypeName: fileAssociation.name,
+ CFBundleTypeName: fileAssociation.name || extensions[0],
CFBundleTypeRole: fileAssociation.role || "Editor",
CFBundleTypeIconFile: iconFile
}
diff --git a/packages/electron-builder/src/targets/nsis.ts b/packages/electron-builder/src/targets/nsis.ts
index a49b09417aa..b50f8ff6921 100644
--- a/packages/electron-builder/src/targets/nsis.ts
+++ b/packages/electron-builder/src/targets/nsis.ts
@@ -268,7 +268,7 @@ export default class NsisTarget extends Target {
const icon = `"${installedIconPath}"`
const commandText = `"Open with ${packager.appInfo.productName}"`
const command = '"$appExe $\\"%1$\\""'
- registerFileAssociationsScript += ` !insertmacro APP_ASSOCIATE "${ext}" "${item.name}" "${item.description || ""}" ${icon} ${commandText} ${command}\n`
+ registerFileAssociationsScript += ` !insertmacro APP_ASSOCIATE "${ext}" "${item.name || ext}" "${item.description || ""}" ${icon} ${commandText} ${command}\n`
}
}
script = `!macro registerFileAssociations\n${registerFileAssociationsScript}!macroend\n${script}`
@@ -277,7 +277,7 @@ export default class NsisTarget extends Target {
let unregisterFileAssociationsScript = ""
for (const item of fileAssociations) {
for (const ext of asArray(item.ext)) {
- unregisterFileAssociationsScript += ` !insertmacro APP_UNASSOCIATE "${normalizeExt(ext)}" "${item.name}"\n`
+ unregisterFileAssociationsScript += ` !insertmacro APP_UNASSOCIATE "${normalizeExt(ext)}" "${item.name || ext}"\n`
}
}
script = `!macro unregisterFileAssociations\n${unregisterFileAssociationsScript}!macroend\n${script}`