Lines 1-59javascript
1import { execSync } from 'child_process';
2import { existsSync, statSync } from 'fs';
HighChild Process
Package source references child process execution.
dist/format-on-save.jsView on unpkg · L1 4// src/format-on-save/index.ts
5var API_VERSION = "^0.1.10";
8 /** Times formatting was applied (file changed). */
10 /** Times the file was already formatted (no change). */
12 /** Times biome failed (not installed, timeout, parse error). */
14 /** Hook handle for teardown. */
16 /** Last format result — surfaced by health() + status tool. */
23function readConfig(raw) {
24 if (!raw || typeof raw !== "object") return { ...DEFAULTS };
27 enabled: r["enabled"] !== false,
28 timeoutMs: typeof r["timeoutMs"] === "number" && r["timeoutMs"] > 0 ? r["timeoutMs"] : DEFAULTS.timeoutMs
31function formatFile(filePath, timeoutMs) {
32 if (!existsSync(filePath)) return null;
35 bytesBefore = statSync(filePath).size;
40 execSync(`npx biome format --write "${filePath}"`, {
41 encoding: "utf-8",
HighRuntime Package Install
Package source invokes a package manager install command at runtime.
dist/format-on-save.jsView on unpkg · L39 44 stdio: ["pipe", "pipe", "pipe"]
48 if (e.killed) return null;
52 bytesAfter = statSync(filePath).size;
56 if (bytesAfter !== bytesBefore) {
57 return { changed: true, bytesBefore, bytesAfter };