Skip to content

Commit

Permalink
fix(nsis): nondestructive removal of install directory
Browse files Browse the repository at this point in the history
  • Loading branch information
amr-crabnebula committed Jul 18, 2024
1 parent 522f23b commit 4580d67
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
7 changes: 7 additions & 0 deletions .changes/nsis-graceful-remove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"cargo-packager": "patch"
"@crabnebula/packager": "patch"
---

Fix NSIS uninstaller removing the uninstall directory even if it was not empty.

24 changes: 18 additions & 6 deletions bindings/packager/nodejs/src-ts/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ export type Resource =
target: string;
[k: string]: unknown;
};
/**
* A list of dependencies specified as either a list of Strings or as a path to a file that lists the dependencies, one per line.
*/
export type Dependencies = string[] | string;
/**
* A wix language.
*/
Expand Down Expand Up @@ -409,6 +413,8 @@ export interface MacOsConfig {
exceptionDomain?: string | null;
/**
* Code signing identity.
*
* This is typically of the form: `"Developer ID Application: TEAM_NAME (TEAM_ID)"`.
*/
signingIdentity?: string | null;
/**
Expand All @@ -425,19 +431,25 @@ export interface MacOsConfig {
infoPlistPath?: string | null;
}
/**
* The Linux debian configuration.
* The Linux Debian configuration.
*/
export interface DebianConfig {
/**
* The list of debian dependencies.
* The list of Debian dependencies.
*/
depends?: string[] | null;
depends?: Dependencies | null;
/**
* Path to a custom desktop file Handlebars template.
*
* Available variables: `categories`, `comment` (optional), `exec`, `icon` and `name`.
*
* Default file contents: ```text [Desktop Entry] Categories={{categories}} {{#if comment}} Comment={{comment}} {{/if}} Exec={{exec}} Icon={{icon}} Name={{name}} Terminal=false Type=Application {{#if mime_type}} MimeType={{mime_type}} {{/if}} ```
* Default file contents: ```text [Desktop Entry] Categories={{categories}} {{#if comment}} Comment={{comment}} {{/if}} Exec={{exec}} {{exec_arg}} Icon={{icon}} Name={{name}} Terminal=false Type=Application {{#if mime_type}} MimeType={{mime_type}} {{/if}} ```
*
* The `{{exec_arg}}` will be set to: * "%F", if at least one [Config::file_associations] was specified but no deep link protocols were given. * The "%F" arg means that your application can be invoked with multiple file paths. * "%U", if at least one [Config::deep_link_protocols] was specified. * The "%U" arg means that your application can be invoked with multiple URLs. * If both [Config::file_associations] and [Config::deep_link_protocols] were specified, the "%U" arg will be used, causing the file paths to be passed to your app as `file://` URLs. * An empty string "" (nothing) if neither are given. * This means that your application will never be invoked with any URLs or file paths.
*
* To specify a custom `exec_arg`, just use plaintext directly instead of `{{exec_arg}}`: ```text Exec={{exec}} %u ```
*
* See more here: <https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#exec-variables>.
*/
desktopTemplate?: string | null;
/**
Expand Down Expand Up @@ -497,9 +509,9 @@ export interface PacmanConfig {
/**
* List of softwares that must be installed for the app to build and run.
*
* See : <https://wiki.archlinux.org/title/PKGBUILD#provides>
* See : <https://wiki.archlinux.org/title/PKGBUILD#depends>
*/
depends?: string[] | null;
depends?: Dependencies | null;
/**
* Additional packages that are provided by this app.
*
Expand Down
12 changes: 4 additions & 8 deletions crates/packager/src/package/nsis/installer.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -610,14 +610,10 @@ Section Uninstall
; Delete uninstaller
Delete "$INSTDIR\uninstall.exe"

${If} $DeleteAppDataCheckboxState == 1
RMDir /R /REBOOTOK "$INSTDIR"
${Else}
{{#each resources_dirs}}
RMDir /REBOOTOK "$INSTDIR\\{{this}}"
{{/each}}
RMDir "$INSTDIR"
${EndIf}
{{#each resources_dirs}}
RMDir /REBOOTOK "$INSTDIR\\{{this}}"
{{/each}}
RMDir "$INSTDIR"

; Remove start menu shortcut
!insertmacro MUI_STARTMENU_GETFOLDER Application $AppStartMenuFolder
Expand Down

0 comments on commit 4580d67

Please sign in to comment.