* Find the longest (possibly multi-dot) extension registered in `Module._extensions`. * @param {string} filename The filename to find the longest registered extension for. * @returns {string}
(filename)
| 621 | * @returns {string} |
| 622 | */ |
| 623 | function findLongestRegisteredExtension(filename) { |
| 624 | const name = path.basename(filename); |
| 625 | let currentExtension; |
| 626 | let index; |
| 627 | let startIndex = 0; |
| 628 | while ((index = StringPrototypeIndexOf(name, '.', startIndex)) !== -1) { |
| 629 | startIndex = index + 1; |
| 630 | if (index === 0) { continue; } // Skip dotfiles like .gitignore |
| 631 | currentExtension = StringPrototypeSlice(name, index); |
| 632 | if (Module._extensions[currentExtension]) { return currentExtension; } |
| 633 | } |
| 634 | return '.js'; |
| 635 | } |
| 636 | |
| 637 | /** |
| 638 | * Tries to get the absolute file path of the parent module. |
no outgoing calls
no test coverage detected
searching dependent graphs…