MCPcopy Index your code
hub / github.com/callstack/agent-device / ensureAndroidSdkPathConfigured

Function ensureAndroidSdkPathConfigured

src/platforms/android/sdk.ts:41–74  ·  view source on GitHub ↗
(
  env: NodeJS.ProcessEnv = process.env,
)

Source from the content-addressed store, hash-verified

39}
40
41export async function ensureAndroidSdkPathConfigured(
42 env: NodeJS.ProcessEnv = process.env,
43): Promise<void> {
44 const existingDirs: string[] = [];
45 let detectedRoot: string | undefined;
46
47 for (const sdkRoot of resolveAndroidSdkRoots(env)) {
48 const presentDirs: string[] = [];
49 for (const relativeDir of ANDROID_SDK_BIN_DIRS) {
50 const candidate = path.join(sdkRoot, relativeDir);
51 if (await pathExists(candidate)) {
52 presentDirs.push(candidate);
53 }
54 }
55 if (presentDirs.length === 0) continue;
56 if (!detectedRoot) {
57 detectedRoot = sdkRoot;
58 }
59 existingDirs.push(...presentDirs);
60 }
61
62 if (detectedRoot) {
63 env.ANDROID_SDK_ROOT = env.ANDROID_SDK_ROOT?.trim() || detectedRoot;
64 env.ANDROID_HOME = env.ANDROID_HOME?.trim() || detectedRoot;
65 }
66
67 if (existingDirs.length === 0) return;
68
69 const currentEntries = (env.PATH ?? '')
70 .split(path.delimiter)
71 .map((entry) => entry.trim())
72 .filter((entry) => entry.length > 0);
73 env.PATH = uniqueNonEmpty([...existingDirs, ...currentEntries]).join(path.delimiter);
74}

Callers 3

listAndroidDevicesFunction · 0.90
sdk.test.tsFile · 0.90

Calls 4

resolveAndroidSdkRootsFunction · 0.85
pathExistsFunction · 0.85
uniqueNonEmptyFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected