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