diff --git a/packages/shared-lib-node/src/env.ts b/packages/shared-lib-node/src/env.ts index e8e8b4aa..9cd6a831 100644 --- a/packages/shared-lib-node/src/env.ts +++ b/packages/shared-lib-node/src/env.ts @@ -109,7 +109,7 @@ export function readEnvironmentVariables( /** * This function read environment variables from `.env` files and assign them in `process.env`. * */ -export function readAndUpdateEnvironmentVariables( +export function readAndApplyEnvironmentVariables( argv: EnvReaderOptions, cwd: string, cacheEnabled = true diff --git a/packages/shared-lib-node/src/index.ts b/packages/shared-lib-node/src/index.ts index f8c95ba5..19110a4a 100644 --- a/packages/shared-lib-node/src/index.ts +++ b/packages/shared-lib-node/src/index.ts @@ -1,6 +1,6 @@ export { readEnvironmentVariables, - readAndUpdateEnvironmentVariables, + readAndApplyEnvironmentVariables, removeNpmAndYarnEnvironmentVariables, yargsOptionsBuilderForEnv, } from './env.js'; diff --git a/packages/shared-lib-node/tests/env.test.ts b/packages/shared-lib-node/tests/env.test.ts index 2f1b871f..9f527a13 100644 --- a/packages/shared-lib-node/tests/env.test.ts +++ b/packages/shared-lib-node/tests/env.test.ts @@ -1,6 +1,6 @@ import { beforeEach, describe, expect, it } from 'vitest'; -import { readAndUpdateEnvironmentVariables } from '../src/env.js'; +import { readAndApplyEnvironmentVariables } from '../src/env.js'; describe('readAndApplyEnvironmentVariables()', () => { beforeEach(() => { @@ -9,39 +9,36 @@ describe('readAndApplyEnvironmentVariables()', () => { }); it('should load no env vars with empty options', () => { - const envVars = readAndUpdateEnvironmentVariables({}, 'test-fixtures/app1'); + const envVars = readAndApplyEnvironmentVariables({}, 'test-fixtures/app1'); expect(envVars).toEqual({}); }); it('should load env vars with --auto-cascade-env', () => { - const envVars = readAndUpdateEnvironmentVariables({ autoCascadeEnv: true }, 'test-fixtures/app1'); + const envVars = readAndApplyEnvironmentVariables({ autoCascadeEnv: true }, 'test-fixtures/app1'); expect(envVars).toEqual({ NAME: 'app1', ENV: 'development1' }); }); it('should load env vars with --cascade-env=production', () => { - const envVars = readAndUpdateEnvironmentVariables( - { cascadeEnv: 'production', env: ['.env'] }, - 'test-fixtures/app1' - ); + const envVars = readAndApplyEnvironmentVariables({ cascadeEnv: 'production', env: ['.env'] }, 'test-fixtures/app1'); expect(envVars).toEqual({ NAME: 'app1', ENV: 'production1' }); }); it('should load env vars with --cascade-node-env and NODE_ENV=""', () => { process.env.NODE_ENV = ''; - const envVars = readAndUpdateEnvironmentVariables({ cascadeNodeEnv: true, env: ['.env'] }, 'test-fixtures/app1'); + const envVars = readAndApplyEnvironmentVariables({ cascadeNodeEnv: true, env: ['.env'] }, 'test-fixtures/app1'); expect(envVars).toEqual({ NAME: 'app1', ENV: 'development1' }); }); it('should load env vars with --cascade-node-env and NODE_ENV=test', () => { process.env.NODE_ENV = 'test'; - const envVars = readAndUpdateEnvironmentVariables({ cascadeNodeEnv: true, env: ['.env'] }, 'test-fixtures/app1'); + const envVars = readAndApplyEnvironmentVariables({ cascadeNodeEnv: true, env: ['.env'] }, 'test-fixtures/app1'); expect(envVars).toEqual({ NAME: 'app1', ENV: 'test1' }); }); it('should load env vars with --env=test-fixtures/app2/.env --auto-cascade-env, WB_ENV=test and NODE_ENV=production', () => { process.env.WB_ENV = 'test'; process.env.NODE_ENV = 'production'; - const envVars = readAndUpdateEnvironmentVariables( + const envVars = readAndApplyEnvironmentVariables( { autoCascadeEnv: true, env: ['../app2/.env'] }, 'test-fixtures/app1' );