(filePath: string)
| 98 | } |
| 99 | |
| 100 | export function detectFileEncoding(filePath: string): BufferEncoding { |
| 101 | try { |
| 102 | const fs = getFsImplementation() |
| 103 | const { resolvedPath } = safeResolvePath(fs, filePath) |
| 104 | return detectEncodingForResolvedPath(resolvedPath) |
| 105 | } catch (error) { |
| 106 | if (isFsInaccessible(error)) { |
| 107 | logForDebugging( |
| 108 | `detectFileEncoding failed for expected reason: ${error.code}`, |
| 109 | { |
| 110 | level: 'debug', |
| 111 | }, |
| 112 | ) |
| 113 | } else { |
| 114 | logError(error) |
| 115 | } |
| 116 | return 'utf8' |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | export function detectLineEndings( |
| 121 | filePath: string, |
no test coverage detected