makensis
A Node wrapper for makensis
, the compiler for NSIS installers. Supports both, native compilers and Wine.
Prerequisites
Make sure that NSIS is properly installed with makensis
in your PATH environmental variable.
On non-Windows platforms, you can usually install NSIS with your package manager:
sudo apt-get install nsis
sudo dnf install nsis
brew install nsis
port install nsis
Alternatively, you can setup NSIS in your Wine environment. Keep in mind that Wine writes standard streams while running makensis
, so additional parsing of the compiler output might be necessary.
Installation
yarn add makensis || npm install makensis
Usage
Use ES6 imports or require()
to include the module:
import * as makensis from 'makensis';
const makensis = require('makensis');
Example usage in script:
import * as makensis from 'makensis';
const options = {
verbose: 2,
define: {
'SPECIAL_BUILD': true
}
}
makensis.compile('/path/to/installer.nsi', options)
.then(output => {
console.log('Standard output:\n' + output.stdout);
}).catch(output => {
console.error(`Exit Code ${output.status}: ${output.stderr}`);
});
let output = makensis.compileSync('/path/to/installer.nsi', options);
if (output.status === 0) {
console.log('Standard output:\n' + output.stdout);
} else {
console.error(`Exit Code ${output.status}: ${output.stderr}`);
}
Methods
compile
Usage: compile(script, [options])
Compiles specified script with MakeNSIS. The script can be omitted in favor of execute
.
compileSync
Usage: compileSync(script, [options])
Compiles specified script with MakeNSIS. The script can be omitted in favor of execute
.
version
Usage: version()
Returns version of MakeNSIS. Equivalent of the -VERSION
switch.
versionSync
Usage: versionSync()
Returns version of MakeNSIS. Equivalent of the -VERSION
switch.
hdrinfo
Usage: hdrInfo()
Returns information about which options were used to compile MakeNSIS. Equivalent of the -HDRINFO
switch.
hdrInfoSync
Usage: hdrInfoSync()
Returns information about which options were used to compile MakeNSIS. Equivalent of the -HDRINFO
switch.
cmdHelp
Usage: cmdHelp([command])
Returns usage information for a specific command, or a list all commands. Equivalent of the -CMDHELP
switch.
cmdHelpSync
Usage: cmdHelpSync([command])
Returns usage information for a specific command, or a list all commands. Equivalent of the -CMDHELP
switch.
MakeNSIS Options
Note: Some of these options are limited to NSIS v3 (see the changelog for details)
verbose
Type: integer
Verbosity where x is 4=all,3=no script,2=no info,1=no warnings,0=none. Equivalent of the -V
switch.
pause
Type: boolean
Pauses after execution. Equivalent of the -PAUSE
switch.
noCD
Type: boolean
Disables the current directory change to that of the .nsi file. Equivalent of the -NOCD
switch.
noConfig
Type: boolean
Disables inclusion of <path to makensis.exe>/nsisconf.nsh
. Equivalent of the -NOCONFIG
switch.
inputCharset
Type: string
allows you to specify a specific codepage for files without a BOM (ACP|OEM|CP#|UTF8|UTF16<LE|BE>
). Equivalent of the -INPUTCHARSET
switch.
outputCharset
Type: string
Allows you to specify the codepage used by stdout when the output is redirected (ACP|OEM|CP#|UTF8[SIG]|UTF16<LE|BE>[BOM]
). Equivalent of the -OUTPUTCHARSET
switch.
strict
Type: boolean
Treat warnings as errors. Equivalent of the -WX
switch.
ppo / safePPO
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.
define
Type: Object
Defines symbols for the script [to value]. Equivalent of the -D
switch.
Example:
define: {
"SPECIAL_BUILD": true,
"LANGUAGE": "English"
}
execute
Type: Array
Executes script-commands in the script, parameters are processed by order. Equivalent of the -X
switch
Example:
execute: [
"SetCompressor lzma",
"SetCompressorDictSize 16"
]
wine
Type: boolean
Run makensis
on Wine
Spawn Options
cwd
Type: string
Current working directory of the child process
detached
Type: boolean
Prepare child to run independently of its parent process. Specific behavior depends on the platform, see options.detached
.
shell
Type: boolean|string
If true, runs command inside of a shell. Uses /bin/sh
on UNIX, and process.env.ComSpec
on Windows. A different shell can be specified as a string. See Shell Requirements and Default Windows Shell.
Other Options
pathToMakensis
Type: string
Specifies a custom path to makensis
License
This work is licensed under The MIT License
Donate
You are welcome support this project using Flattr or Bitcoin 17CXJuPsmhuTzFV2k4RKYwpEHVjskJktRd