Skip to content

Commit

Permalink
feat(nsis): custom uninstaller display name in the control panel
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed Jun 14, 2017
1 parent 58c5522 commit fda6ee9
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 20 deletions.
1 change: 1 addition & 0 deletions docs/Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ Configuration Options
* <a name="NsisOptions-language"></a>`language` String - [LCID Dec](https://msdn.microsoft.com/en-au/goglobal/bb964664.aspx), defaults to `1033`(`English - United States`).
* <a name="NsisOptions-multiLanguageInstaller"></a>`multiLanguageInstaller` Boolean - *boring installer only.* Whether to create multi-language installer. Defaults to `unicode` option value. [Not all strings are translated](https://github.com/electron-userland/electron-builder/issues/646#issuecomment-238155800).
* <a name="NsisOptions-menuCategory"></a>`menuCategory` = `false` Boolean | String - Whether to create submenu for start menu shortcut and program files directory. If `true`, company name will be used. Or string value.
* <a name="NsisOptions-uninstallDisplayName"></a>`uninstallDisplayName` = `${productName} ${version}` String - The uninstaller display name in the control panel.
* <a name="NsisOptions-artifactName"></a>`artifactName` String - The [artifact file name pattern](https://github.com/electron-userland/electron-builder/wiki/Options#artifact-file-name-pattern). Defaults to `${productName} Setup ${version}.${ext}`.
* <a name="NsisOptions-deleteAppDataOnUninstall"></a>`deleteAppDataOnUninstall` = `false` Boolean - *one-click installer only.* Whether to delete app data on uninstall.
* <a name="NsisOptions-packElevateHelper"></a>`packElevateHelper` = `true` Boolean - Whether to pack the elevate executable (required for electron-updater if per-machine installer used or can be used in the future). Ignored if `perMachine` is set to `true`.
Expand Down
36 changes: 20 additions & 16 deletions docs/api/electron-builder.md
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@
* [`.getElectronDestDir(appOutDir)`](#module_electron-builder/out/platformPackager.PlatformPackager+getElectronDestDir) ⇒ <code>String</code>
* [`.getElectronSrcDir(dist)`](#module_electron-builder/out/platformPackager.PlatformPackager+getElectronSrcDir) ⇒ <code>String</code>
* [`.expandArtifactNamePattern(targetSpecificOptions, ext, arch, defaultPattern, skipArchIfX64)`](#module_electron-builder/out/platformPackager.PlatformPackager+expandArtifactNamePattern) ⇒ <code>String</code>
* [`.expandMacro(pattern, arch, extra)`](#module_electron-builder/out/platformPackager.PlatformPackager+expandMacro) ⇒ <code>String</code>
* [`.expandMacro(pattern, arch, extra, isProductNameSanitized)`](#module_electron-builder/out/platformPackager.PlatformPackager+expandMacro) ⇒ <code>String</code>
* [`.generateName(ext, arch, deployment, classifier)`](#module_electron-builder/out/platformPackager.PlatformPackager+generateName) ⇒ <code>String</code>
* [`.generateName2(ext, classifier, deployment)`](#module_electron-builder/out/platformPackager.PlatformPackager+generateName2) ⇒ <code>String</code>
* [`.getIconPath()`](#module_electron-builder/out/platformPackager.PlatformPackager+getIconPath) ⇒ <code>Promise&lt; \| String&gt;</code>
Expand Down Expand Up @@ -498,7 +498,7 @@
* [`.getElectronDestDir(appOutDir)`](#module_electron-builder/out/platformPackager.PlatformPackager+getElectronDestDir) ⇒ <code>String</code>
* [`.getElectronSrcDir(dist)`](#module_electron-builder/out/platformPackager.PlatformPackager+getElectronSrcDir) ⇒ <code>String</code>
* [`.expandArtifactNamePattern(targetSpecificOptions, ext, arch, defaultPattern, skipArchIfX64)`](#module_electron-builder/out/platformPackager.PlatformPackager+expandArtifactNamePattern) ⇒ <code>String</code>
* [`.expandMacro(pattern, arch, extra)`](#module_electron-builder/out/platformPackager.PlatformPackager+expandMacro) ⇒ <code>String</code>
* [`.expandMacro(pattern, arch, extra, isProductNameSanitized)`](#module_electron-builder/out/platformPackager.PlatformPackager+expandMacro) ⇒ <code>String</code>
* [`.generateName(ext, arch, deployment, classifier)`](#module_electron-builder/out/platformPackager.PlatformPackager+generateName) ⇒ <code>String</code>
* [`.generateName2(ext, classifier, deployment)`](#module_electron-builder/out/platformPackager.PlatformPackager+generateName2) ⇒ <code>String</code>
* [`.getIconPath()`](#module_electron-builder/out/platformPackager.PlatformPackager+getIconPath) ⇒ <code>Promise&lt; \| String&gt;</code>
Expand Down Expand Up @@ -585,14 +585,15 @@

<a name="module_electron-builder/out/platformPackager.PlatformPackager+expandMacro"></a>

#### `linuxPackager.expandMacro(pattern, arch, extra)` ⇒ <code>String</code>
#### `linuxPackager.expandMacro(pattern, arch, extra, isProductNameSanitized)` ⇒ <code>String</code>
**Kind**: instance method of [<code>LinuxPackager</code>](#LinuxPackager)

| Param | Type |
| --- | --- |
| pattern | <code>String</code> |
| arch | <code>String</code> \| <code>undefined</code> \| <code>null</code> |
| arch | <code>String</code> \| <code>null</code> |
| extra | <code>any</code> |
| isProductNameSanitized | |

<a name="module_electron-builder/out/platformPackager.PlatformPackager+generateName"></a>

Expand Down Expand Up @@ -685,7 +686,7 @@
* [`.getDefaultIcon(ext)`](#module_electron-builder/out/platformPackager.PlatformPackager+getDefaultIcon) ⇒ <code>Promise&lt; \| String&gt;</code>
* [`.dispatchArtifactCreated(file, target, arch, safeArtifactName)`](#module_electron-builder/out/platformPackager.PlatformPackager+dispatchArtifactCreated)
* [`.expandArtifactNamePattern(targetSpecificOptions, ext, arch, defaultPattern, skipArchIfX64)`](#module_electron-builder/out/platformPackager.PlatformPackager+expandArtifactNamePattern) ⇒ <code>String</code>
* [`.expandMacro(pattern, arch, extra)`](#module_electron-builder/out/platformPackager.PlatformPackager+expandMacro) ⇒ <code>String</code>
* [`.expandMacro(pattern, arch, extra, isProductNameSanitized)`](#module_electron-builder/out/platformPackager.PlatformPackager+expandMacro) ⇒ <code>String</code>
* [`.generateName(ext, arch, deployment, classifier)`](#module_electron-builder/out/platformPackager.PlatformPackager+generateName) ⇒ <code>String</code>
* [`.generateName2(ext, classifier, deployment)`](#module_electron-builder/out/platformPackager.PlatformPackager+generateName2) ⇒ <code>String</code>
* [`.getMacOsResourcesDir(appOutDir)`](#module_electron-builder/out/platformPackager.PlatformPackager+getMacOsResourcesDir) ⇒ <code>String</code>
Expand Down Expand Up @@ -717,7 +718,7 @@
* [`.getDefaultIcon(ext)`](#module_electron-builder/out/platformPackager.PlatformPackager+getDefaultIcon) ⇒ <code>Promise&lt; \| String&gt;</code>
* [`.dispatchArtifactCreated(file, target, arch, safeArtifactName)`](#module_electron-builder/out/platformPackager.PlatformPackager+dispatchArtifactCreated)
* [`.expandArtifactNamePattern(targetSpecificOptions, ext, arch, defaultPattern, skipArchIfX64)`](#module_electron-builder/out/platformPackager.PlatformPackager+expandArtifactNamePattern) ⇒ <code>String</code>
* [`.expandMacro(pattern, arch, extra)`](#module_electron-builder/out/platformPackager.PlatformPackager+expandMacro) ⇒ <code>String</code>
* [`.expandMacro(pattern, arch, extra, isProductNameSanitized)`](#module_electron-builder/out/platformPackager.PlatformPackager+expandMacro) ⇒ <code>String</code>
* [`.generateName(ext, arch, deployment, classifier)`](#module_electron-builder/out/platformPackager.PlatformPackager+generateName) ⇒ <code>String</code>
* [`.generateName2(ext, classifier, deployment)`](#module_electron-builder/out/platformPackager.PlatformPackager+generateName2) ⇒ <code>String</code>
* [`.getMacOsResourcesDir(appOutDir)`](#module_electron-builder/out/platformPackager.PlatformPackager+getMacOsResourcesDir) ⇒ <code>String</code>
Expand Down Expand Up @@ -822,14 +823,15 @@

<a name="module_electron-builder/out/platformPackager.PlatformPackager+expandMacro"></a>

#### `macPackager.expandMacro(pattern, arch, extra)` ⇒ <code>String</code>
#### `macPackager.expandMacro(pattern, arch, extra, isProductNameSanitized)` ⇒ <code>String</code>
**Kind**: instance method of [<code>MacPackager</code>](#MacPackager)

| Param | Type |
| --- | --- |
| pattern | <code>String</code> |
| arch | <code>String</code> \| <code>undefined</code> \| <code>null</code> |
| arch | <code>String</code> \| <code>null</code> |
| extra | <code>any</code> |
| isProductNameSanitized | |

<a name="module_electron-builder/out/platformPackager.PlatformPackager+generateName"></a>

Expand Down Expand Up @@ -916,7 +918,7 @@
* [`.getElectronDestDir(appOutDir)`](#module_electron-builder/out/platformPackager.PlatformPackager+getElectronDestDir) ⇒ <code>String</code>
* [`.getElectronSrcDir(dist)`](#module_electron-builder/out/platformPackager.PlatformPackager+getElectronSrcDir) ⇒ <code>String</code>
* [`.expandArtifactNamePattern(targetSpecificOptions, ext, arch, defaultPattern, skipArchIfX64)`](#module_electron-builder/out/platformPackager.PlatformPackager+expandArtifactNamePattern) ⇒ <code>String</code>
* [`.expandMacro(pattern, arch, extra)`](#module_electron-builder/out/platformPackager.PlatformPackager+expandMacro) ⇒ <code>String</code>
* [`.expandMacro(pattern, arch, extra, isProductNameSanitized)`](#module_electron-builder/out/platformPackager.PlatformPackager+expandMacro) ⇒ <code>String</code>
* [`.generateName(ext, arch, deployment, classifier)`](#module_electron-builder/out/platformPackager.PlatformPackager+generateName) ⇒ <code>String</code>
* [`.generateName2(ext, classifier, deployment)`](#module_electron-builder/out/platformPackager.PlatformPackager+generateName2) ⇒ <code>String</code>
* [`.getIconPath()`](#module_electron-builder/out/platformPackager.PlatformPackager+getIconPath) ⇒ <code>Promise&lt; \| String&gt;</code>
Expand Down Expand Up @@ -960,7 +962,7 @@
* [`.getElectronDestDir(appOutDir)`](#module_electron-builder/out/platformPackager.PlatformPackager+getElectronDestDir) ⇒ <code>String</code>
* [`.getElectronSrcDir(dist)`](#module_electron-builder/out/platformPackager.PlatformPackager+getElectronSrcDir) ⇒ <code>String</code>
* [`.expandArtifactNamePattern(targetSpecificOptions, ext, arch, defaultPattern, skipArchIfX64)`](#module_electron-builder/out/platformPackager.PlatformPackager+expandArtifactNamePattern) ⇒ <code>String</code>
* [`.expandMacro(pattern, arch, extra)`](#module_electron-builder/out/platformPackager.PlatformPackager+expandMacro) ⇒ <code>String</code>
* [`.expandMacro(pattern, arch, extra, isProductNameSanitized)`](#module_electron-builder/out/platformPackager.PlatformPackager+expandMacro) ⇒ <code>String</code>
* [`.generateName(ext, arch, deployment, classifier)`](#module_electron-builder/out/platformPackager.PlatformPackager+generateName) ⇒ <code>String</code>
* [`.generateName2(ext, classifier, deployment)`](#module_electron-builder/out/platformPackager.PlatformPackager+generateName2) ⇒ <code>String</code>
* [`.getIconPath()`](#module_electron-builder/out/platformPackager.PlatformPackager+getIconPath) ⇒ <code>Promise&lt; \| String&gt;</code>
Expand Down Expand Up @@ -1046,14 +1048,15 @@

<a name="module_electron-builder/out/platformPackager.PlatformPackager+expandMacro"></a>

#### `platformPackager.expandMacro(pattern, arch, extra)` ⇒ <code>String</code>
#### `platformPackager.expandMacro(pattern, arch, extra, isProductNameSanitized)` ⇒ <code>String</code>
**Kind**: instance method of [<code>PlatformPackager</code>](#PlatformPackager)

| Param | Type |
| --- | --- |
| pattern | <code>String</code> |
| arch | <code>String</code> \| <code>undefined</code> \| <code>null</code> |
| arch | <code>String</code> \| <code>null</code> |
| extra | <code>any</code> |
| isProductNameSanitized | |

<a name="module_electron-builder/out/platformPackager.PlatformPackager+generateName"></a>

Expand Down Expand Up @@ -1776,7 +1779,7 @@
* [`.getElectronDestDir(appOutDir)`](#module_electron-builder/out/platformPackager.PlatformPackager+getElectronDestDir) ⇒ <code>String</code>
* [`.getElectronSrcDir(dist)`](#module_electron-builder/out/platformPackager.PlatformPackager+getElectronSrcDir) ⇒ <code>String</code>
* [`.expandArtifactNamePattern(targetSpecificOptions, ext, arch, defaultPattern, skipArchIfX64)`](#module_electron-builder/out/platformPackager.PlatformPackager+expandArtifactNamePattern) ⇒ <code>String</code>
* [`.expandMacro(pattern, arch, extra)`](#module_electron-builder/out/platformPackager.PlatformPackager+expandMacro) ⇒ <code>String</code>
* [`.expandMacro(pattern, arch, extra, isProductNameSanitized)`](#module_electron-builder/out/platformPackager.PlatformPackager+expandMacro) ⇒ <code>String</code>
* [`.generateName(ext, arch, deployment, classifier)`](#module_electron-builder/out/platformPackager.PlatformPackager+generateName) ⇒ <code>String</code>
* [`.generateName2(ext, classifier, deployment)`](#module_electron-builder/out/platformPackager.PlatformPackager+generateName2) ⇒ <code>String</code>
* [`.getMacOsResourcesDir(appOutDir)`](#module_electron-builder/out/platformPackager.PlatformPackager+getMacOsResourcesDir) ⇒ <code>String</code>
Expand Down Expand Up @@ -1885,7 +1888,7 @@
* [`.getElectronDestDir(appOutDir)`](#module_electron-builder/out/platformPackager.PlatformPackager+getElectronDestDir) ⇒ <code>String</code>
* [`.getElectronSrcDir(dist)`](#module_electron-builder/out/platformPackager.PlatformPackager+getElectronSrcDir) ⇒ <code>String</code>
* [`.expandArtifactNamePattern(targetSpecificOptions, ext, arch, defaultPattern, skipArchIfX64)`](#module_electron-builder/out/platformPackager.PlatformPackager+expandArtifactNamePattern) ⇒ <code>String</code>
* [`.expandMacro(pattern, arch, extra)`](#module_electron-builder/out/platformPackager.PlatformPackager+expandMacro) ⇒ <code>String</code>
* [`.expandMacro(pattern, arch, extra, isProductNameSanitized)`](#module_electron-builder/out/platformPackager.PlatformPackager+expandMacro) ⇒ <code>String</code>
* [`.generateName(ext, arch, deployment, classifier)`](#module_electron-builder/out/platformPackager.PlatformPackager+generateName) ⇒ <code>String</code>
* [`.generateName2(ext, classifier, deployment)`](#module_electron-builder/out/platformPackager.PlatformPackager+generateName2) ⇒ <code>String</code>
* [`.getMacOsResourcesDir(appOutDir)`](#module_electron-builder/out/platformPackager.PlatformPackager+getMacOsResourcesDir) ⇒ <code>String</code>
Expand Down Expand Up @@ -1995,14 +1998,15 @@

<a name="module_electron-builder/out/platformPackager.PlatformPackager+expandMacro"></a>

#### `winPackager.expandMacro(pattern, arch, extra)` ⇒ <code>String</code>
#### `winPackager.expandMacro(pattern, arch, extra, isProductNameSanitized)` ⇒ <code>String</code>
**Kind**: instance method of [<code>WinPackager</code>](#WinPackager)

| Param | Type |
| --- | --- |
| pattern | <code>String</code> |
| arch | <code>String</code> \| <code>undefined</code> \| <code>null</code> |
| arch | <code>String</code> \| <code>null</code> |
| extra | <code>any</code> |
| isProductNameSanitized | |

<a name="module_electron-builder/out/platformPackager.PlatformPackager+generateName"></a>

Expand Down
6 changes: 6 additions & 0 deletions packages/electron-builder/src/options/winOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,12 @@ export interface NsisOptions extends CommonNsisOptions, TargetSpecificOptions {
*/
readonly menuCategory?: boolean | string

/**
* The uninstaller display name in the control panel.
* @default ${productName} ${version}
*/
readonly uninstallDisplayName?: string

/**
* @private
* @default false
Expand Down
4 changes: 2 additions & 2 deletions packages/electron-builder/src/platformPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>
})
}

expandMacro(pattern: string, arch: string | n, extra: any = {}): string {
expandMacro(pattern: string, arch?: string | null, extra: any = {}, isProductNameSanitized = true): string {
if (arch == null) {
pattern = pattern
.replace("-${arch}", "")
Expand All @@ -390,7 +390,7 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>
return pattern.replace(/\${([_a-zA-Z./*]+)}/g, (match, p1): string => {
switch (p1) {
case "productName":
return appInfo.productFilename
return isProductNameSanitized ? appInfo.productFilename : appInfo.productName

case "arch":
if (arch == null) {
Expand Down
2 changes: 2 additions & 0 deletions packages/electron-builder/src/targets/nsis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,8 @@ export class NsisTarget extends Target {
defines.UNINSTALLER_ICON = uninstallerIcon
defines.MUI_UNICON = uninstallerIcon
}

defines.UNINSTALL_DISPLAY_NAME = packager.expandMacro(this.options.uninstallDisplayName || "${productName} ${version}", null, {}, false)
}

private configureDefinesForAllTypeOfInstaller(defines: any) {
Expand Down
1 change: 0 additions & 1 deletion packages/electron-builder/templates/nsis/multiUser.nsh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

!define INSTALL_REGISTRY_KEY "Software\${APP_GUID}"
!define UNINSTALL_REGISTRY_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_GUID}"
!define UNINSTALL_DISPLAY_NAME "${PRODUCT_NAME} ${VERSION}"

# current Install Mode ("all" or "CurrentUser")
Var installMode
Expand Down
2 changes: 1 addition & 1 deletion test/out/__snapshots__/ExtraBuildTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ Object {
"file": "TestApp-1.1.0-x86_64.AppImage",
},
Object {
"arch": 1,
"arch": 0,
"file": "TestApp-1.1.0-ia32.zip",
"safeArtifactName": "TestApp-1.1.0-ia32.zip",
},
Expand Down
3 changes: 3 additions & 0 deletions test/src/windows/oneClickInstallerTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ test.ifAll("multi language license", app({
targets: Platform.WINDOWS.createTarget("nsis"),
config: {
publish: null,
nsis: {
uninstallDisplayName: "Hi!!!",
}
},
}, {
projectDirCreated: projectDir => {
Expand Down

0 comments on commit fda6ee9

Please sign in to comment.