mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
22 lines
677 B
JavaScript
22 lines
677 B
JavaScript
const fs = require("node:fs");
|
|
const { execFileSync } = require("node:child_process");
|
|
const path = require("node:path");
|
|
|
|
const input = JSON.parse(fs.readFileSync("/dev/stdin", "utf8"));
|
|
const filePath = input.tool_input?.file_path || "";
|
|
const formattable = /\.(ts|tsx|js|jsx|json)$/;
|
|
|
|
if (filePath && formattable.test(filePath) && fs.existsSync(filePath)) {
|
|
const projectRoot = path.resolve(__dirname, "..", "..");
|
|
const biomeBin = path.join(projectRoot, "node_modules", ".bin", "biome");
|
|
|
|
try {
|
|
execFileSync(biomeBin, ["check", "--write", filePath], {
|
|
stdio: "pipe",
|
|
cwd: projectRoot,
|
|
});
|
|
} catch {
|
|
// Format failures are non-blocking
|
|
}
|
|
}
|