@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,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.envConfig = exports.ENV_BUILD_CONFIGS = void 0;
4
- const assertions_1 = require("../assertions");
5
- const guards_1 = require("../guards");
4
+ const _1 = require(".");
6
5
  /**
7
6
  * A list of environment variables that were requested at build time. Used by webpack to
8
7
  * capture build-time environment variables values.
@@ -35,7 +34,17 @@ const envConfig = (name, type = 'build', defaultValue) => {
35
34
  // - https://github.com/webpack/webpack/issues/14800
36
35
  // - https://github.com/webpack/webpack/issues/5392
37
36
  const envs = { ...process.env, ...(typeof __PROCESS_ENV !== 'undefined' ? __PROCESS_ENV : {}) };
38
- return (0, assertions_1.assertDefined)((0, guards_1.ifDefined)(envs[name], defaultValue), `expected to find environment variable with name: ${name}`);
37
+ if (envs[name] === undefined) {
38
+ if (defaultValue === undefined) {
39
+ throw new Error(`expected to find environment variable with name: ${name}`);
40
+ }
41
+ else {
42
+ return (0, _1.resolveConfigValue)(defaultValue);
43
+ }
44
+ }
45
+ else {
46
+ return envs[name];
47
+ }
39
48
  };
40
49
  };
41
50
  exports.envConfig = envConfig;