@nsis/dent
An opinionated code formatter for NSIS scripts
This is the repository for the formatting library powering the
Visual Studio Code andPulsar packages. Chances are you were looking for the CLI tool.
Installation
npm install @nsis/dent
Usage
import { createFormatter } from "@nsis/dent";
const { format } = createFormatter(/* user options */);
format(`
# Look ma, no indentation
Name "Demo"
Section
Nop
SectionEnd
`);
Output of the script above:
# Look ma, no indentation
Name "Demo"
Section
Nop
SectionEnd
API
format(fileContents)
Formats the given NSIS code and returns the result as a string.
check(fileContents)
Returns null if the file is already formatted, otherwise the formatted string.
Options
options.commentStyle
Type: "hash" | "semi"
Default: none
NSIS accepts both # and ; for single-line comments. By default every comment keeps the marker it was written with. Set this option to unify them — "hash" rewrites ; comment to # comment, "semi" does the reverse. Block comments (/* … */) are never touched.
options.endOfLine
Type: "crlf" | "lf"
Default: "crlf" (Windows), "lf" (Linux, macOS)
options.indentSize
Type: number
Default: 2
options.trimEmptyLines
Type: boolean
Default: true
options.printWidth
Type: numbers
Default: 0
options.singleQuote
Type: boolean
Default: false
options.useTabs
Type: boolean
Default: true
Why defaulting to tabs is good for accessibility
Related
License
This work is licensed under The MIT License.