···11+/**
22+ * This script runs oxlint and oxfmt in a CI environment, without the need to install the entire
33+ * project. It reads the required version from pnpm-lock.yaml and executes the linters accordingly.
44+ * It's "stupid by design" so it could work in minimal Node.js environments.
55+ */
66+77+import { spawnSync } from 'node:child_process'
88+99+function getDependencyVersion(dependencyName: string): string {
1010+ const result = spawnSync('npm', ['pkg', 'get', `devDependencies.${dependencyName}`], {
1111+ encoding: 'utf8',
1212+ })
1313+1414+ if (result.status) {
1515+ throw new Error(`Command failed: pnpm info ${dependencyName} version`)
1616+ }
1717+1818+ return JSON.parse(result.stdout)
1919+}
2020+2121+function runCommand(command: string, args: string[]) {
2222+ const result = spawnSync(command, args, { stdio: 'inherit' })
2323+2424+ if (result.status) {
2525+ throw new Error(`Command failed: ${command} ${args.join(' ')}`)
2626+ }
2727+}
2828+2929+const oxlintVersion = getDependencyVersion('oxlint')
3030+const oxfmtVersion = getDependencyVersion('oxfmt')
3131+3232+runCommand('pnpx', [`oxlint@${oxlintVersion}`])
3333+runCommand('pnpx', [`oxfmt@${oxfmtVersion}`, '--check'])