Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

904 B
Raw Blame
import { spawnSync } from 'node:child_process'

/**
 * Format JS/TS files using `hogli format:js`.
 *
 * @param {string[]} files - absolute paths to format
 * @param {string} hogliPath - absolute path to the hogli binary
 * @param {string} cwd - working directory for the hogli call
 */
export function formatJs(files, hogliPath, cwd) {
    if (files.length === 0) {
        return
    }
    spawnSync(hogliPath, ['format:js', ...files], { stdio: 'pipe', cwd })
}

/**
 * Format JSON/YAML files using `hogli format:yaml` (runs oxfmt).
 *
 * @param {string[]} files - absolute paths to format
 * @param {string} hogliPath - absolute path to the hogli binary
 * @param {string} cwd - working directory for the hogli call
 */
export function formatYaml(files, hogliPath, cwd) {
    if (files.length === 0) {
        return
    }
    spawnSync(hogliPath, ['format:yaml', ...files], { stdio: 'pipe', cwd })
}