(fileRef: string)
| 57 | } |
| 58 | |
| 59 | export 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 | |
| 73 | export function coerceString(value: string | object): string { |
| 74 | if (typeof value === 'string') { |
no test coverage detected
searching dependent graphs…