MCPcopy Create free account
hub / github.com/reactnativecn/react-native-update / detectAndroidAvdName

Function detectAndroidAvdName

Example/e2etest/.detoxrc.ts:44–78  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

42}
43
44function detectAndroidAvdName() {
45 if (process.env.DETOX_AVD_NAME) {
46 return process.env.DETOX_AVD_NAME;
47 }
48
49 if (process.platform !== 'darwin' && process.platform !== 'linux') {
50 return 'Pixel_3a_API_33_arm64-v8a';
51 }
52
53 try {
54 const output = execSync('emulator -list-avds', {
55 stdio: ['ignore', 'pipe', 'ignore'],
56 }).toString();
57 const avds = output
58 .split('\n')
59 .map(line => line.trim())
60 .filter(Boolean);
61
62 const preferredPatterns = [/^api34$/i, /\bapi[_-]?34\b/i, /\b34\b/];
63 for (const pattern of preferredPatterns) {
64 const preferredAvd = avds.find(item => pattern.test(item));
65 if (preferredAvd) {
66 return preferredAvd;
67 }
68 }
69
70 if (avds.length > 0) {
71 return avds[0];
72 }
73 } catch {
74 // fall through to default
75 }
76
77 return 'api34';
78}
79
80const iosSimulatorType = detectIosSimulatorType();
81const androidAvdName = detectAndroidAvdName();

Callers 1

.detoxrc.tsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected