1import { execSync } from 'child_process' 5export const getPtnodeShellInvokersH = (): Record<string, string[]> => { 6 const resultH: Record<string, string[]> = {} 8 const rgOutput = execSync( 10 { encoding: 'utf8', cwd: ptDir, maxBuffer: 10 * 1024 * 1024 } 12 for (const line of rgOutput.trim().split('\n').filter(Boolean)) { 13 const match = line.match(/^\.\/(.+?):(\d+):ptnode\s+(\S+)/) 15 const [, scriptPath, , invokedPath] = match 16 resultH[scriptPath] ||= [] 17 resultH[scriptPath].push(invokedPath) 20 if (e.status !== 1) throw e 25export const getPtnodeShellInvokers = (filePath: string) => { 26 const invokersH = getPtnodeShellInvokersH() 27 const resultA: string[] = [] 28 for (const [script, invokedA] of Object.entries(invokersH)) { 29 if (invokedA.includes(filePath)) resultA.push(script)