* Determine whether a file should be normalized (text formatting enforced) based on its path. * @param {string} relPath - File path relative to the repository root. * @returns {boolean} `true` if the file extension is in TEXT_EXTENSIONS or the basename is `.gitignore` or `.gitattributes`, `false`
(relPath)
| 78 | * @returns {boolean} `true` if the file extension is in TEXT_EXTENSIONS or the basename is `.gitignore` or `.gitattributes`, `false` otherwise. |
| 79 | */ |
| 80 | function shouldFormat(relPath) { |
| 81 | const ext = path.extname(relPath).toLowerCase(); |
| 82 | if (TEXT_EXTENSIONS.has(ext)) { |
| 83 | return true; |
| 84 | } |
| 85 | |
| 86 | const baseName = path.basename(relPath); |
| 87 | return baseName === '.gitignore' || baseName === '.gitattributes'; |
| 88 | } |
| 89 | |
| 90 | function normalizeText(content) { |
| 91 | let next = content.replace(/\r\n/g, '\n'); |
no test coverage detected