Files
life-echo/app-expo/scripts/use-env.js
2026-03-23 13:21:07 +08:00

23 lines
762 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 将 app-expo/.env.<name> 复制为 .env供 Metro/Expo 读取 EXPO_PUBLIC_*。
*
* 参数 name → 源文件:
* development → .env.development本地默认npm start / prestart
* staging → .env.staging
* production → .env.production
*
* CI.github/workflows/app-expo-deploy.yml 按分支/tag 调用本脚本,与后端 env 策略对齐。
*/
const fs = require('fs');
const path = require('path');
const env = process.argv[2] || 'development';
const src = path.join(__dirname, '..', `.env.${env}`);
const dest = path.join(__dirname, '..', '.env');
if (fs.existsSync(src)) {
fs.copyFileSync(src, dest);
console.log(`Switched to .env.${env}`);
} else {
console.error(`Missing .env.${env}`);
process.exit(1);
}