(path: string)
| 10 | const BINARY_EXTENSIONS = ['.png', '.jpg', '.jpeg', '.gif', '.svg', '.ico'] |
| 11 | |
| 12 | export function readFileHelper(path: string): string { |
| 13 | if (isBinaryFile(path)) { |
| 14 | return `base64::${readFileSync(path).toString('base64')}` |
| 15 | } else { |
| 16 | return readFileSync(path, 'utf-8').toString() |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | export function isBinaryFile(path: string): boolean { |
| 21 | return BINARY_EXTENSIONS.includes(extname(path)) |
no test coverage detected