A TypeScript wrapper for makensis, the compiler for NSIS installers.
Make sure that NSIS 3.06 (or later) is installed. If makensis isn't exposed to your PATH environment variable, you need to set pathToMakensis.
Windows
Install NSIS using the Windows Package Manager or Scoop:
# Windows Package Manager
$ winget install NSIS.NSIS
# Scoop
$ scoop install nsis/nsisAlternatively, you can download the NSIS installer from SourceForge.
Linux
Install NSIS from your distribution's default package manager, for example:
# Debian
$ sudo apt-get install nsis
# Red Hat
$ sudo dnf install nsis
# Arch Linux
$ pacman -S nsismacOS
Install NSIS using Homebrew or MacPorts:
# Homebrew
$ brew install nsis
# MacPorts
$ port install nsis# NodeJS
npm install makensis
# Deno
deno add jsr:@idleberg/makensisWarning
If you need to support a version of NSIS older than 3.06, you can use makensis@2 as it employs some useful workarounds.
Example usage in script:
import * as NSIS from "makensis";
const options = {
verbose: 2,
define: {
SPECIAL_BUILD: true,
},
};
try {
const output = await NSIS.compile("path/to/installer.nsi", options);
console.log("Compiler output:", output);
} catch (error) {
console.error(error);
}Usage: commandHelp(command?, options?, spawnOptions?)
Returns usage information for a specific command, or a list of all commands. Equivalent of the -CMDHELP switch.
Usage: compile(script, options?, spawnOptions?)
Compiles the specified script with MakeNSIS. The script can be omitted in favour of the preExecute / postExecute options.
Usage: headerInfo(options?, spawnOptions?)
Returns information about which options were used to compile MakeNSIS. Equivalent of the -HDRINFO switch.
Usage: license(options?, spawnOptions?)
Returns MakeNSIS software license. Equivalent of the -LICENSE switch.
Usage: nsisDir(options?, spawnOptions?)
Returns the path of ${NSISDIR}.
Usage: version(options?, spawnOptions?)
Returns the version of MakeNSIS. Equivalent of the -VERSION switch.
Type: Object
Defines symbols for the script [to value]. Equivalent of the -D switch.
Example
define: {
SPECIAL_BUILD: true,
LANGUAGE: "English"
}Type: boolean
Enables support for special environment variables that will be passed on to the script as definitions.
Example
# .env
NSIS_APP_ENVIRONMENT=development# installer.nsi
!if ${NSIS_APP_ENVIRONMENT} == "development"
DetailPrint "Valuable Debug Information"
!endifType: string
Specifies the codepage for files without a BOM (ACP|OEM|CP#|UTF8|UTF16<LE|BE>). Equivalent of the -INPUTCHARSET switch.
Warning
This option is only available on Windows.
Type: string
Specifies the codepage used by stdout when the output is redirected (ACP|OEM|CP#|UTF8[SIG]|UTF16<LE|BE>[BOM]). Equivalent of the -OUTPUTCHARSET switch.
Type: boolean
Returns output from makensis as an object
Type: boolean
Disables the current directory change to that of the .nsi file. Equivalent of the -NOCD switch.
Type: boolean
Disables inclusion of <path to makensis.exe>/nsisconf.nsh. Equivalent of the -NOCONFIG switch.
Type: string
Specifies a custom path to makensis
Type: boolean
Pauses after execution. Equivalent of the -PAUSE switch.
Warning
This option is only available on Windows.
Type: integer
Sets the compiler process priority, where the value 5=realtime, 4=high, 3=above normal, 2=normal, 1=below normal, 0=idle. Equivalent of the -P switch.
Type: boolean
Treat warnings as errors. Equivalent of the -WX switch.
Type: boolean
Will only run the preprocessor and print the result to stdout. The safe version will not execute instructions like !appendfile or !system. !packhdr and !finalize are never executed. Equivalent of the -PPO / SAFEPPO switches.
Type: string | string[]
Prepends script-commands to the script, can be passed as an array or multiline string. Equivalent of the -X switch when used before passing a script.
Example
preExecute: ["SetCompressor lzma", "SetCompressorDictSize 16"];Type: string | string[]
Appends commands to the script, can be passed as an array or multiline script. Equivalent of the -X switch when used after passing a script.
Example
postExecute: [`!echo "That's all Folks!"`];Type: string[]
Specifies raw arguments for makensis.
Important
These will be added to the compiler arguments last and will hence overwrite any of the NSIS options above!
Type: integer
Verbosity where the value 4=all, 3=no script,2=no info, 1=no warnings, 0=none. Equivalent of the -V switch.
Gives access to an object containing the current line, whether it contains a warning, and the path of the outfile.
Gives access to an object containing the current line.
Gives access to an object containing the exit code, the full stdout and stderr, and the number of warnings.
- atom-language-nsis - NSIS package for Atom/Pulsar
- vscode-nsis - NSIS package for Visual Studio Code
This work is licensed under The MIT License.