mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
8 lines
320 B
TypeScript
8 lines
320 B
TypeScript
import { readFileSync } from 'fs'
|
|
|
|
export function extractShellFunction(scriptPath: string, name: string): string {
|
|
const match = readFileSync(scriptPath, 'utf-8').match(new RegExp(`^${name}\\(\\) \\{\\n[\\s\\S]*?\\n\\}`, 'm'))
|
|
if (!match) throw new Error(`${name}() not found in ${scriptPath}`)
|
|
return match[0]
|
|
}
|