( file: string, platforms?: Array<string>, )
| 9 | |
| 10 | // Extract platform extension: index.ios.js -> ios |
| 11 | export default function getPlatformExtension( |
| 12 | file: string, |
| 13 | platforms?: Array<string>, |
| 14 | ): string | null { |
| 15 | const last = file.lastIndexOf('.'); |
| 16 | const secondToLast = file.lastIndexOf('.', last - 1); |
| 17 | if (secondToLast === -1) { |
| 18 | return null; |
| 19 | } |
| 20 | const platform = file.slice(secondToLast + 1, last); |
| 21 | // If an overriding platform array is passed, check that first |
| 22 | |
| 23 | if (platforms && platforms.includes(platform)) { |
| 24 | return platform; |
| 25 | } |
| 26 | return SUPPORTED_PLATFORM_EXTS.has(platform) ? platform : null; |
| 27 | } |
no outgoing calls
no test coverage detected