MCPcopy
hub / github.com/jestjs/jest / getPlatformExtension

Function getPlatformExtension

packages/jest-haste-map/src/lib/getPlatformExtension.ts:11–27  ·  view source on GitHub ↗
(
  file: string,
  platforms?: Array<string>,
)

Source from the content-addressed store, hash-verified

9
10// Extract platform extension: index.ios.js -> ios
11export 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}

Callers 5

setModuleMethod · 0.85
_processFileMethod · 0.85
onChangeMethod · 0.85
_recoverDuplicatesMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected