| 87 | |
| 88 | // 当前应用如果作为 git submodule 存在,加载父级目录是的环境配置文件 |
| 89 | export function tryLoadParentGitRepoEnv(options = {}) { |
| 90 | if (!fs.existsSync(path.resolve('..', '.gitmodules'))) return |
| 91 | const envPaths = [path.resolve('..', '.env'), path.resolve('..', '.env.' + process.env.NODE_ENV)] |
| 92 | for (const envPath of envPaths) { |
| 93 | if (!fs.existsSync(envPath)) continue |
| 94 | dotenv.config({ |
| 95 | path: envPath, |
| 96 | override: true, |
| 97 | }) |
| 98 | } |
| 99 | if (!options.silentParentEnvHint) { |
| 100 | console.log(zx.chalk.cyan('💡 当前项目作为 git submodule,已加载主目录环境配置')) |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | |
| 105 | export function checkEnvs() { |