MCPcopy Create free account
hub / github.com/craftreactnative/ui / detectAliasFromImports

Function detectAliasFromImports

cli/src/utils/file-system.ts:37–57  ·  view source on GitHub ↗
(content: string)

Source from the content-addressed store, hash-verified

35 * Returns the detected alias or null if none found
36 */
37export function detectAliasFromImports(content: string): string | null {
38 const lines = content.split("\n");
39
40 for (const line of lines) {
41 const trimmed = line.trim();
42 if (trimmed.startsWith("import ")) {
43 // Look for common alias patterns in existing imports
44 if (trimmed.includes('from "@/') || trimmed.includes("from '@/")) {
45 return "@";
46 }
47 if (trimmed.includes('from "~/') || trimmed.includes("from '~/")) {
48 return "~";
49 }
50 if (trimmed.includes('from "src/') || trimmed.includes("from 'src/")) {
51 return "src";
52 }
53 }
54 }
55
56 return null;
57}

Callers 1

determineImportPathFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected