npm.io
0.17.0 • Published 2 weeks ago

@nsis/dent

Licence
MIT
Version
0.17.0
Deps
1
Size
46 kB
Vulns
0
Weekly
0

@nsis/dent

An opinionated code formatter for NSIS scripts

License Version Build

This is the repository for the formatting library powering the Visual Studio Code and Pulsar packages. Chances are you were looking for the CLI tool.

Demo Time

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

License

This work is licensed under The MIT License.

Keywords