@openstax/ts-utils 1.5.0 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,4 @@
1
- import { assertDefined } from '../assertions';
2
- import { ifDefined } from '../guards';
1
+ import { resolveConfigValue } from '.';
3
2
  /**
4
3
  * A list of environment variables that were requested at build time. Used by webpack to
5
4
  * capture build-time environment variables values.
@@ -32,6 +31,16 @@ export const envConfig = (name, type = 'build', defaultValue) => {
32
31
  // - https://github.com/webpack/webpack/issues/14800
33
32
  // - https://github.com/webpack/webpack/issues/5392
34
33
  const envs = { ...process.env, ...(typeof __PROCESS_ENV !== 'undefined' ? __PROCESS_ENV : {}) };
35
- return assertDefined(ifDefined(envs[name], defaultValue), `expected to find environment variable with name: ${name}`);
34
+ if (envs[name] === undefined) {
35
+ if (defaultValue === undefined) {
36
+ throw new Error(`expected to find environment variable with name: ${name}`);
37
+ }
38
+ else {
39
+ return resolveConfigValue(defaultValue);
40
+ }
41
+ }
42
+ else {
43
+ return envs[name];
44
+ }
36
45
  };
37
46
  };