Skip to content

Commit

Permalink
Merge branch 'main' into feat/dmg-config
Browse files Browse the repository at this point in the history
  • Loading branch information
amr-crabnebula authored Dec 1, 2023
2 parents 1584cd9 + 9b56eaf commit ca8b2a6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
11 changes: 9 additions & 2 deletions crates/packager/src/package/nsis/installer.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ Section Install

; Copy resources
{{#each resources}}
File /a "/oname={{this.[1]}}" "{{this.[0]}}"
File /a "/oname={{this}}" "{{@key}}"
{{/each}}

; Copy external binaries
Expand Down Expand Up @@ -588,7 +588,14 @@ Section Uninstall
; Delete uninstaller
Delete "$INSTDIR\uninstall.exe"

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

; Remove start menu shortcut
!insertmacro MUI_STARTMENU_GETFOLDER Application $AppStartMenuFolder
Expand Down
12 changes: 11 additions & 1 deletion crates/packager/src/package/nsis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,9 +449,19 @@ fn build_nsis_app_installer(ctx: &Context, nsis_path: &Path) -> crate::Result<Ve
data.insert("out_file", to_json(out_file));

let (resources_dirs, resources) = generate_resource_data(config)?;
data.insert("resources_dirs", to_json(resources_dirs));
data.insert("resources_dirs", to_json(&resources_dirs));
data.insert("resources", to_json(&resources));

let mut resources_ancestors = resources_dirs
.iter()
.flat_map(|p| p.ancestors())
.collect::<Vec<_>>();
resources_ancestors.sort_unstable();
resources_ancestors.dedup();
resources_ancestors.sort_by_key(|p| std::cmp::Reverse(p.components().count()));
resources_ancestors.pop(); // Last one is always ""
data.insert("resources_ancestors", to_json(resources_ancestors));

let binaries = generate_binaries_data(config)?;
data.insert("binaries", to_json(&binaries));

Expand Down

0 comments on commit ca8b2a6

Please sign in to comment.