Skip to content

Commit 7ed9d7a

Browse files
michel-klijndevelar
authored andcommitted
feat(nsins): create pre initialization hook in installer.nsi (#1255)
Create a 'preInit' hook in the NSIS installer script that is inserted before any other code or macros. This allows customs macros to access the initial state of global variables.
1 parent 8a75cbb commit 7ed9d7a

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

docs/NSIS.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,16 @@ Two options are available — [include](https://github.com/electron-userland/ele
99
Keep in mind — if you customize NSIS script, you should always state about it in the issue reports. And don't expect that your issue will be resolved.
1010

1111
1. Add file `build/installer.nsh`.
12-
2. Define wanted macro to customise: `customHeader`, `customInit`, `customUnInit`, `customInstall`, `customUnInstall`. Example:
12+
2. Define wanted macro to customise: `customHeader`, `preInit`, `customInit`, `customUnInit`, `customInstall`, `customUnInstall`. Example:
1313
```nsis
1414
!macro customHeader
1515
!system "echo '' > ${BUILD_RESOURCES_DIR}/customHeader"
1616
!macroend
17+
18+
!macro preInit
19+
; This macro is inserted at the beginning of the NSIS .OnInit callback
20+
!system "echo '' > ${BUILD_RESOURCES_DIR}/preInit"
21+
!macroend
1722
1823
!macro customInit
1924
!system "echo '' > ${BUILD_RESOURCES_DIR}/customInit"

packages/electron-builder/templates/nsis/installer.nsi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ Var desktopLink
3333
!endif
3434

3535
Function .onInit
36+
!ifmacrodef preInit
37+
!insertmacro preInit
38+
!endif
3639
!ifdef BUILD_UNINSTALLER
3740
WriteUninstaller "${UNINSTALLER_OUT_FILE}"
3841
!insertmacro quitSuccess

0 commit comments

Comments
 (0)