Files
cindy/apps/mobile/scripts/lib/sim-environment.mjs
Dash 9018f7c47a fix(mobile): 统一模拟器启动身份校验并保留依赖现场 (#4599)
* fix(mobile): 统一模拟器启动身份校验并保留依赖现场

Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>

* fix(mobile): 复用模拟器 UDID 参数解析并修正文档示例

Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>

---------

Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
2026-09-17 17:01:22 +07:00

22 lines
1008 B
JavaScript

import { readFileSync, existsSync } from 'node:fs';
import { join } from 'node:path';
import { parseProjectEnv } from '@expo/env';
import { metroEnvironmentFingerprint } from '../sim-metro.mjs';
/** Read the same inputs for start, diagnostics and rebuild, without repairing files. */
export function readSimEnvironment(mobileDir, buildEnv, systemEnv = process.env) {
const projectEnv = parseProjectEnv(mobileDir, {
mode: systemEnv.NODE_ENV ?? 'development', silent: true, systemEnv: { ...systemEnv },
});
const loginScenario = systemEnv.EXPO_PUBLIC_LOGIN_SCENARIO?.trim()
?? projectEnv.env.EXPO_PUBLIC_LOGIN_SCENARIO?.trim() ?? '';
const files = {};
for (const name of ['.env', 'scripts/self-host-regions.json']) {
const file = join(mobileDir, name);
files[name] = existsSync(file) ? readFileSync(file, 'utf8') : null;
}
return { loginScenario, envFingerprint: metroEnvironmentFingerprint({
env: { ...buildEnv, EXPO_PUBLIC_LOGIN_SCENARIO: loginScenario }, files,
}) };
}