Registry / devops / pike-fmt

pike-fmt

JSON →
library0.1.6jsnpmunverified

pike-fmt is a standalone source code formatter for the Pike programming language, built on tree-sitter-pike for AST-aware formatting. Current stable version is 0.1.6, released with monthly cadence. It normalizes indentation (2-space), whitespace, and optionally operator spacing. Key differentiators: first dedicated Pike formatter, uses Tree-sitter for accurate parsing, and supports CLI flags for check/diff/list/write modes.

npm install pike-fmt
INSTALL
IMPORT
SIG · PIKE-FMT
P
pike-fmt
devopsjavascriptv0.1.6
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

format
import { format } from 'pike-fmt'
const format = require('pike-fmt');
Package exports ESM only; CommonJS require is not supported.
formatString
import { formatString } from 'pike-fmt'
import formatString from 'pike-fmt';
formatString is not a default export.
CLI
import { CLI } from 'pike-fmt/cli'
import { cli } from 'pike-fmt';
CLI is a separate entry point; must import from 'pike-fmt/cli' with correct casing.

Demonstrates programmatic usage with formatString and format functions, plus CLI invocation.

import { formatString, format } from 'pike-fmt'; // Format a string const code = `int main() { return 0; }`; const formatted = formatString(code); console.log(formatted); // Format a file (async) const fs = await import('fs/promises'); const fileContent = await fs.readFile('example.pike', 'utf-8'); const formattedFile = format(fileContent); console.log(formattedFile); // CLI usage // bun run src/cli.ts < file.pike // bun run src/cli.ts -w . --check
Debug
Known issues
breakingImport from 'pike-fmt' is ESM-only; CommonJS require fails.
fix
Use import syntax or enable ESM in package.json with 'type': 'module'.
affects: >=0.1
gotchaformatString() does not accept file paths; only raw code strings.
fix
Use format() with file content read via fs.readFileSync/fs.promises.
affects: >=0.1.0
deprecatedThe CLI flag --operator-spacing is experimental and may change.
fix
Check future releases for stabilization; use cautiously.
affects: >=0.1.0
gotchaThe formatter always enforces 2-space indentation and no space before '(' in function calls.
fix
No customization; if different style needed, file an issue or fork.
affects: >=0.1.0
breakingOutput may differ from original if file contains non-standard Pike syntax.
fix
Ensure input is valid Pike; errors are not handled gracefully.
affects: >=0.1.0
Errors
Common errors & fixes
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'pike-fmt'
Package not installed or not in node_modules.
fix
npm install pike-fmt or bun install pike-fmt
SyntaxError: Unexpected token 'export'
Using CommonJS require() on an ESM-only package.
fix
Change to import or set 'type': 'module' in package.json.
TypeError: formatString is not a function
Incorrect import: imported as default instead of named.
fix
Use import { formatString } from 'pike-fmt'
Upgrade
Version history
0.1.6latest on npm
Audit
Dependencies
noderequiredRequires Node.js runtime for CLI execution
Agent activity
6 hits · last 30 days
node
6
Resources
pike-fmt — npm install pike-fmt · libregistry