makensis
A Node wrapper for makensis
, the compiler for NSIS installers. Supports both, native 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 preExecute
/ postExecute
.
compileSync
Usage: compileSync(script, [options])
Compiles specified script with MakeNSIS. The script can be omitted in favor of preExecute
/ postExecute
..
version
Usage: version([options])
Returns version of MakeNSIS. Equivalent of the -VERSION
switch.
versionSync
Usage: versionSync([options])
Returns version of MakeNSIS. Equivalent of the -VERSION
switch.
hdrInfo
Usage: hdrInfo([options])
Returns information about which options were used to compile MakeNSIS. Equivalent of the -HDRINFO
switch.
hdrInfoSync
Usage: hdrInfoSync([options])
Returns information about which options were used to compile MakeNSIS. Equivalent of the -HDRINFO
switch.
cmdHelp
Usage: cmdHelp([command], [options])
Returns usage information for a specific command, or a list all commands. Equivalent of the -CMDHELP
switch.
cmdHelpSync
Usage: cmdHelpSync([command], [options])
Returns usage information for a specific command, or a list all commands. Equivalent of the -CMDHELP
switch.
Options
MakeNSIS
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.
Alias: nocd
noConfig
Type: boolean
Disables inclusion of <path to makensis.exe>/nsisconf.nsh
. Equivalent of the -NOCONFIG
switch.
Alias: noconfig
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.
Alias: inputcharset
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.
Alias: outputcharset
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.
Alias: PPO
/ safeppo
define
Type: Object
Defines symbols for the script [to value]. Equivalent of the -D
switch.
Example:
define: {
"SPECIAL_BUILD": true,
"LANGUAGE": "English"
}
preExecute
Type: Array|string
Prepends script-commands to the script, parameters are processed by order. Equivalent of the -X
switch
Example:
preExecute: [
"SetCompressor lzma",
"SetCompressorDictSize 16"
]
Alias: execute
postExecute
Type: Array|string
Appends script-commands to the script, parameters are processed by order. Equivalent of the -X
switch
Example:
postExecute: [
"SetCompressor lzma",
"SetCompressorDictSize 16"
]
wine
Type: boolean
Run makensis
on Wine
Spawn
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
json
Type: boolean
Return output from makensis
as an object
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