dprint-plugin-pwsh
v0.2.0
Published
PowerShell dprint plugin (plugin.wasm) packaged for @dprint/formatter hosts
Maintainers
Readme
dprint-plugin-pwsh
The PowerShell dprint plugin
as an npm package: plugin.wasm plus getPath()/getBuffer() accessors,
following the convention of @dprint/json, @dprint/typescript, and
friends. No runtime dependencies.
Using the dprint CLI? You don't need this package — run
dprint add kjanat/pwsh instead. This package is for hosting the plugin
from JavaScript via @dprint/formatter,
and for a richer JS API (structured diagnostics, range formatting) see
pwsh-formatter.
Usage
import { createFromBuffer } from "@dprint/formatter";
import { getBuffer } from "dprint-plugin-pwsh";
const formatter = createFromBuffer(getBuffer());
formatter.setConfig({}, { indentWidth: 4 });
console.log(formatter.formatText({
filePath: "script.ps1",
fileText: "function foo {\n'hi'\n }\n",
}));@dprint/formatter is your dependency, not this package's.
As a dprint CLI install source
The packaged wasm also works directly in a dprint.json plugins array —
from the npm CDN mirrors, or offline from an installed node_modules:
{
"pwsh": {},
"plugins": [
// pick one:
"https://cdn.jsdelivr.net/npm/[email protected]/plugin.wasm",
"./node_modules/dprint-plugin-pwsh/plugin.wasm"
]
}The primary CLI path remains dprint add kjanat/pwsh (update notifications,
checksummed latest.json).
