MCPcopy Create free account
hub / github.com/Y80/bmm / loadEnv

Function loadEnv

scripts/utils.mjs:73–85  ·  view source on GitHub ↗
(options = {})

Source from the content-addressed store, hash-verified

71
72// 加载环境变量
73export async function loadEnv(options = {}) {
74 // 命令行传入 -P 或 --production 将使用正式环境变量
75 const args = zx.minimist(process.argv.slice(2), { alias: { production: 'P' } })
76 const isProduction = args.production === true
77 if (!process.env.NODE_ENV) {
78 // 不考虑 test 的情况
79 process.env.NODE_ENV = isProduction ? 'production' : 'development'
80 }
81 const NextEnv = await import('@next/env')
82 const loadEnvConfig = NextEnv.loadEnvConfig || NextEnv.default.loadEnvConfig
83 loadEnvConfig(process.cwd(), isProduction)
84 tryLoadParentGitRepoEnv(options)
85}
86
87
88// 当前应用如果作为 git submodule 存在,加载父级目录是的环境配置文件

Callers 8

vitest.config.tsFile · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
db-init.mjsFile · 0.90
mainFunction · 0.90
mainFunction · 0.90

Calls 1

tryLoadParentGitRepoEnvFunction · 0.85

Tested by

no test coverage detected