MCPcopy Create free account
hub / github.com/NativeScript/NativeScript / resolveNativeScriptPlatformFile

Function resolveNativeScriptPlatformFile

packages/vite/helpers/utils.ts:41–58  ·  view source on GitHub ↗
(id: string, platform: string)

Source from the content-addressed store, hash-verified

39 * @returns The resolved file path or undefined if not found.
40 */
41export function resolveNativeScriptPlatformFile(id: string, platform: string): string | undefined {
42 const ext = path.extname(id);
43 const base = id.slice(0, -ext.length);
44
45 let platformFile = `${base}.${platform}${ext}`;
46 if (fs.existsSync(platformFile)) {
47 return platformFile;
48 }
49
50 // core uses indices for many barrels
51 platformFile = `${base}/index.${platform}${ext}`;
52 if (fs.existsSync(platformFile)) {
53 return platformFile;
54 }
55
56 // fallback to non-platform file
57 return fs.existsSync(id) ? id : undefined;
58}
59
60/**
61 * Utility to get all dependencies from the project package.json.

Callers 2

resolveIdFunction · 0.85
resolveIdFunction · 0.85

Calls 1

sliceMethod · 0.45

Tested by

no test coverage detected