MCPcopy
hub / github.com/vercel/next.js / replaceProcessEnv

Function replaceProcessEnv

packages/next-env/index.ts:29–43  ·  view source on GitHub ↗
(sourceEnv: Env)

Source from the content-addressed store, hash-verified

27}
28
29function replaceProcessEnv(sourceEnv: Env) {
30 Object.keys(process.env).forEach((key) => {
31 // Allow mutating internal Next.js env variables after the server has initiated.
32 // This is necessary for dynamic things like the IPC server port.
33 if (!key.startsWith('__NEXT_PRIVATE')) {
34 if (sourceEnv[key] === undefined || sourceEnv[key] === '') {
35 delete process.env[key]
36 }
37 }
38 })
39
40 Object.entries(sourceEnv).forEach(([key, value]) => {
41 process.env[key] = value
42 })
43}
44
45export function processEnv(
46 loadedEnvFiles: LoadedEnvFiles,

Callers 2

resetEnvFunction · 0.85
loadEnvConfigFunction · 0.85

Calls 4

startsWithMethod · 0.80
keysMethod · 0.65
forEachMethod · 0.45
entriesMethod · 0.45

Tested by

no test coverage detected