(value: T, root: string)
| 227 | const PLUGIN_ROOT_RE = /\$\{?(?:CLAUDE_PLUGIN_ROOT|PLUGIN_ROOT)\}?/g; |
| 228 | |
| 229 | function substitutePluginRoot<T>(value: T, root: string): T { |
| 230 | if (typeof value === 'string') return value.replace(PLUGIN_ROOT_RE, root) as unknown as T; |
| 231 | if (Array.isArray(value)) return value.map(v => substitutePluginRoot(v, root)) as unknown as T; |
| 232 | if (value && typeof value === 'object') { |
| 233 | const out: any = {}; |
| 234 | for (const [k, v] of Object.entries(value)) out[k] = substitutePluginRoot(v as any, root); |
| 235 | return out; |
| 236 | } |
| 237 | return value; |
| 238 | } |
| 239 | |
| 240 | async function readJsonIfExists(file: string): Promise<any | null> { |
| 241 | try { return JSON.parse(await fs.readFile(file, 'utf-8')); } catch { return null; } |
no outgoing calls
no test coverage detected