MCPcopy
hub / github.com/promptfoo/promptfoo / implementation

Function implementation

test/util/testCaseReader.test.ts:59–83  ·  view source on GitHub ↗
(config: any)

Source from the content-addressed store, hash-verified

57}));
58const mockMaybeLoadConfigFromExternalFileImpl = vi.hoisted(() => {
59 const implementation = (config: any): any => {
60 if (Array.isArray(config)) {
61 return config.map((item) => implementation(item));
62 }
63
64 if (typeof config === 'object' && config !== null) {
65 const result = { ...config };
66 for (const [key, value] of Object.entries(config)) {
67 if (typeof value === 'string' && value.startsWith('file://')) {
68 const filePath = value.slice('file://'.length);
69 const fileContent = mockReadFileSync(filePath, 'utf-8');
70 if (typeof fileContent === 'string') {
71 try {
72 result[key] = JSON.parse(fileContent);
73 } catch {
74 result[key] = fileContent;
75 }
76 }
77 }
78 }
79 return result;
80 }
81
82 return config;
83 };
84
85 return implementation;
86});

Callers

nothing calls this directly

Calls 2

mockReadFileSyncFunction · 0.85
parseMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…