🌳
pt0/deployF/jsImportsF/ptAnchorIncludesAI.mts
1import { execSync } from 'child_process'
5export const getPtnodeShellInvokersH = (): Record<string, string[]> => {
6 const resultH: Record<string, string[]> = {}
7 try {
8 const rgOutput = execSync(
9 `rg -n "^ptnode " --glob "*/${pathBinDirname}/*" .`,
10 { encoding: 'utf8', cwd: ptDir, maxBuffer: 10 * 1024 * 1024 }
11 )
12 for (const line of rgOutput.trim().split('\n').filter(Boolean)) {
13 const match = line.match(/^\.\/(.+?):(\d+):ptnode\s+(\S+)/)
14 if (!match) continue
15 const [, scriptPath, , invokedPath] = match
16 resultH[scriptPath] ||= []
17 resultH[scriptPath].push(invokedPath)
18 }
19 } catch (e: any) {
20 if (e.status !== 1) throw e
21 }
22 return resultH
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)
30 }
31 return resultA