MCPcopy Index your code
hub / github.com/promptfoo/promptfoo / processFileReference

Function processFileReference

src/assertions/utils.ts:59–71  ·  view source on GitHub ↗
(fileRef: string)

Source from the content-addressed store, hash-verified

57}
58
59export function processFileReference(fileRef: string): object | string {
60 const basePath = cliState.basePath || '';
61 const filePath = path.resolve(basePath, fileRef.slice('file://'.length));
62 const fileContent = fs.readFileSync(filePath, 'utf8');
63 const extension = path.extname(filePath);
64 if (['.json', '.yaml', '.yml'].includes(extension)) {
65 return yaml.load(fileContent) as object;
66 } else if (extension === '.txt') {
67 return fileContent.trim();
68 } else {
69 throw new Error(`Unsupported file type: ${filePath}`);
70 }
71}
72
73export function coerceString(value: string | object): string {
74 if (typeof value === 'string') {

Callers 2

utils.test.tsFile · 0.90
runAssertionFunction · 0.90

Calls 1

resolveMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…