Skip to content

wasm-fmt/shfmt

Repository files navigation

Test

Install

npm

npm install @wasm-fmt/shfmt

jsr.io

npx jsr add @fmt/shfmt

Usage

import init, { format } from "@wasm-fmt/shfmt";

await init();

const source = `#!/bin/bash
echo "hello world"
`;

const formatted = format(source);
console.log(formatted);

With options:

const formatted = format(source, "script.sh", {
  indent: 2,
  binaryNextLine: true,
  switchCaseIndent: false,
  spaceRedirects: true,
  keepPadding: false,
  funcNextLine: false,
  minify: false,
  simplify: true
});

Build from source

# 1. install Go https://go.dev/doc/install

# 2. install TinyGo https://tinygo.org/getting-started/install/

# 3. clone this repo
git clone https://github.com/wasm-fmt/shfmt.git

# 4. install dependencies inside the repo
npm

# 5. build
npm run build

# 6. test
npm run test:node

About

A WASM Based Shell Script Formatter

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages