A WASM shell parser and formatter with bash support, based on `mvdan/sh`
https://npmx.dev/sh-syntax β HEALTH ? 82 / Healthy
A WASM shell parser and formatter with bash support, based on `mvdan/sh`
https://npmx.dev/sh-syntax β// readme
A WASM shell parser and formatter with bash support, based on mvdan/sh
# yarn
yarn add sh-syntax
# npm
npm i sh-syntax
import { init, parse, print } from 'sh-syntax'
// Optional: load and initialize the WASM runtime up front.
await init()
const text = "echo 'Hello World!'"
const ast = await parse(text)
// print() formats source text.
const formatted = await print(text)
// print(ast) prints the current tree, including edits made to its fields.
// print(ast) serializes the tree to Go and decodes it before printing. For
// large files, the originalText path below is much faster.
const printedAst = await print(ast)
// originalText still selects the source-text fast path.
const formattedSource = await print(ast, { originalText: text })
Theβ¦