MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / substitutePluginRoot

Function substitutePluginRoot

src/integrations/claude-plugins.ts:229–238  ·  view source on GitHub ↗
(value: T, root: string)

Source from the content-addressed store, hash-verified

227const PLUGIN_ROOT_RE = /\$\{?(?:CLAUDE_PLUGIN_ROOT|PLUGIN_ROOT)\}?/g;
228
229function 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
240async function readJsonIfExists(file: string): Promise<any | null> {
241 try { return JSON.parse(await fs.readFile(file, 'utf-8')); } catch { return null; }

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected