fix(dev): make hooks and bash seams safer

This commit is contained in:
Tianyi Cui
2026-06-17 21:26:44 +08:00
parent b920239389
commit 513e16f9dc
8 changed files with 41 additions and 8 deletions

View File

@@ -0,0 +1,13 @@
#!/usr/bin/env node
import { existsSync } from 'node:fs'
import { spawnSync } from 'node:child_process'
import { join } from 'node:path'
const git = spawnSync('git', ['rev-parse', '--git-dir'], { stdio: 'ignore' })
if (git.status !== 0) process.exit(0)
const lefthook = join(process.cwd(), 'node_modules', '.bin', process.platform === 'win32' ? 'lefthook.cmd' : 'lefthook')
if (!existsSync(lefthook)) process.exit(0)
const result = spawnSync(lefthook, ['install', '--force'], { stdio: 'inherit' })
process.exit(result.status ?? 1)