@karmaniverous/get-dotenv 3.0.6 → 3.1.0

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.
package/README.md CHANGED
@@ -6,10 +6,14 @@ Load environment variables with a cascade of environment-aware dotenv files. You
6
6
  - Load variables for a specific environment or none.
7
7
  - Define dynamic variables progressively in terms of other variables and other logic.
8
8
  - Exclude public, private, global, environment-specific, or dynamic variables.
9
+ - Specify explicit variables to include.
9
10
  - Extract the resulting variables to an object, `process.env`, a dotenv file, or a logger, in any combination.
11
+ - Execute a shell command within the resulting environment. You can even nest additional `getdotenv` calls!
10
12
  - Specify the directories containing your dotenv files.
11
13
  - Specify the filename token that identifies dotenv files (e.g. '.env').
12
14
  - Specify the filename extension that identifies private variables (e.g. 'local').
15
+ - Set defaults for all options in a [`getdotenv.config.json`](./getdotenv.config.json) file in your project root directory.
16
+ - Generate a custom `getdotenv`-based CLI for use in your own projects.
13
17
 
14
18
  `getdotenv` relies on the excellent [`dotenv`](https://www.npmjs.com/package/dotenv) parser and uses [`dotenv-expand`](https://www.npmjs.com/package/dotenv-expand) for recursive variable expansion.
15
19
 
@@ -63,7 +67,6 @@ Since keys will be evaluated progressively, each successive key function will ha
63
67
 
64
68
  Implementation always runs a little behind documentation. These topics & improvements are coming soon:
65
69
 
66
- - Rationalize the package's JSDOC to improve the API documentation below.
67
70
  - An example of dotenv-based environment config.
68
71
  - Integrating `getdotenv` into your npm scripts.
69
72
  - Creating a `getdotenv`-based CLI.
@@ -71,57 +74,56 @@ Implementation always runs a little behind documentation. These topics & improve
71
74
 
72
75
  # Command Line Interface
73
76
 
74
- Note that the defaults below can be changed in your own environment by deriving your base CLI using the `getCli` function.
77
+ Note that the defaults below can be changed in your own environment by deriving your base CLI using the `getDotenvCli` function or placing a `getdotenv.options.json` file in your project root directory.
75
78
 
76
79
  ```text
77
80
  Usage: getdotenv [options] [command]
78
81
 
79
- Base CLI. All options except delimiters follow dotenv-expand rules.
82
+ Base CLI.
80
83
 
81
84
  Options:
82
- -e, --env <string> target environment
83
- --default-env <string> default target environment (default: "dev")
84
- -p, --paths <string> delimited list of paths to dotenv directory (default: "./")
85
- --paths-delimiter <string> regex paths delimiter (default: "\\s+")
86
- -v, --vars <string> delimited list KEY=VALUE pairs
87
- --vars-delimiter <string> regex vars delimiter (default: "\\s+")
88
- --vars-assignor <string> regex vars assignment operator (default: "=")
89
- -y, --dynamic-path <string> dynamic variables path
90
- -o, --output-path <string> consolidated output file, follows dotenv-expand rules using loaded env vars
91
- -n, --exclude-env exclude environment-specific variables
92
- -N, --exclude-env-off exclude environment-specific variables OFF (default)
93
- -g, --exclude-global exclude global variables
94
- -G, --exclude-global-off exclude global variables OFF (default)
95
- -r, --exclude-private exclude private variables
96
- -R, --exclude-private-off exclude private variables OFF (default)
97
- -u, --exclude-public exclude public variables
98
- -U, --exclude-public-off exclude public variables OFF (default)
99
- -z, --exclude-dynamic exclude dynamic variables
100
- -Z, --exclude-dynamic-off exclude dynamic variables OFF (default)
101
- -l, --log console log extracted variables
102
- -L, --log-off console log extracted variables OFF (default)
103
- -x, --suppress-dotenv suppress dotenv loading (default: false)
104
- -c, --command <string> shell command string
105
- --dotenv-token <string> token indicating a dotenv file (default: ".env")
106
- --private-token <string> token indicating private variables (default: "local")
107
- -D, --debug debug mode
108
- -h, --help display help for command
85
+ -e, --env <string> target environment
86
+ -v, --vars <string> dotenv-expanded delimited key-value pairs: KEY1=VAL1 KEY2=VAL2 (default: "")
87
+ -c, --command <string> dotenv-expanded shell command string
88
+ -o, --output-path <string> consolidated output file, follows dotenv-expand rules using loaded env vars
89
+ -p, --load-process load variables to process.env ON (default)
90
+ -P, --load-process-off load variables to process.env OFF
91
+ -a, --exclude-all exclude all dotenv variables from loading ON
92
+ -A, --exclude-all-off exclude all dotenv variables from loading OFF (default)
93
+ -z, --exclude-dynamic exclude dynamic dotenv variables from loading ON
94
+ -Z, --exclude-dynamic-off exclude dynamic dotenv variables from loading OFF (default)
95
+ -n, --exclude-env exclude environment-specific dotenv variables from loading
96
+ -N, --exclude-env-off exclude environment-specific dotenv variables from loading OFF (default)
97
+ -g, --exclude-global exclude global dotenv variables from loading ON
98
+ -G, --exclude-global-off exclude global dotenv variables from loading OFF (default)
99
+ -r, --exclude-private exclude private dotenv variables from loading ON
100
+ -R, --exclude-private-off exclude private dotenv variables from loading OFF (default)
101
+ -u, --exclude-public exclude public dotenv variables from loading ON
102
+ -U, --exclude-public-off exclude public dotenv variables from loading OFF (default)
103
+ -l, --log console log loaded variables ON
104
+ -L, --log-off console log loaded variables OFF (default)
105
+ -d, --debug debug mode ON
106
+ -D, --debug-off debug mode OFF (default)
107
+ --default-env <string> default target environment (default: "dev")
108
+ --dotenv-token <string> dotenv-expanded token indicating a dotenv file (default: ".env")
109
+ --dynamic-path <string> dynamic variables path (default: "./env/dynamic.js")
110
+ --paths <string> dotenv-expanded delimited list of paths to dotenv directory (default: "./ ./env")
111
+ --paths-delimiter <string> paths delimiter string (default: " ")
112
+ --paths-delimiter-pattern <string> paths delimiter regex pattern (default: "\\s+")
113
+ --private-token <string> dotenv-expanded token indicating private variables (default: "local")
114
+ --vars-delimiter <string> vars delimiter string (default: " ")
115
+ --vars-delimiter-pattern <string> vars delimiter regex pattern (default: "\\s+")
116
+ --vars-assignor <string> vars assignment operator string (default: "=")
117
+ --vars-assignor-pattern <string> vars assignment operator regex pattern (default: "=")
118
+ -h, --help display help for command
109
119
 
110
120
  Commands:
111
- cmd execute shell command string (default command)
112
- help [command] display help for command
121
+ cmd execute shell command string (default command)
122
+ help [command] display help for command
113
123
  ```
114
124
 
115
125
  # API Documentation
116
126
 
117
- ## Constants
118
-
119
- <dl>
120
- <dt><a href="#getCli">getCli</a> ⇒ <code>object</code></dt>
121
- <dd><p>Generate a CLI for get-dotenv.</p>
122
- </dd>
123
- </dl>
124
-
125
127
  ## Functions
126
128
 
127
129
  <dl>
@@ -131,40 +133,25 @@ Commands:
131
133
  <dt><a href="#getDotenvSync">getDotenvSync([options])</a> ⇒ <code>Object</code></dt>
132
134
  <dd><p>Synchronously process dotenv files of the form .env[.<ENV>][.<PRIVATETOKEN>]</p>
133
135
  </dd>
136
+ <dt><a href="#getDotenvCli">getDotenvCli([options])</a> ⇒ <code>object</code></dt>
137
+ <dd><p>Generate a CLI for get-dotenv.</p>
138
+ </dd>
134
139
  </dl>
135
140
 
136
141
  ## Typedefs
137
142
 
138
143
  <dl>
139
- <dt><a href="#GetDotenvCliOptions">GetDotenvCliOptions</a> : <code>Object</code></dt>
140
- <dd><p>GetDotenv CLI Options type</p>
144
+ <dt><a href="#GetDotenvOptions">GetDotenvOptions</a> : <code>Object</code></dt>
145
+ <dd><p>get-dotenv options type</p>
141
146
  </dd>
142
- <dt><a href="#GetDotenvPreHookCallback">GetDotenvPreHookCallback</a> ⇒ <code><a href="#GetDotenvCliOptions">GetDotenvCliOptions</a></code></dt>
147
+ <dt><a href="#GetDotenvPreHookCallback">GetDotenvPreHookCallback</a> ⇒ <code>GetDotenvCliOptions</code></dt>
143
148
  <dd><p>GetDotenv CLI Pre-hook Callback type. Transforms inbound options &amp; executes side effects.</p>
144
149
  </dd>
145
150
  <dt><a href="#GetDotenvPostHookCallback">GetDotenvPostHookCallback</a> : <code>function</code></dt>
146
151
  <dd><p>GetDotenv CLI Post-hook Callback type. Executes side effects within getdotenv context.</p>
147
152
  </dd>
148
- <dt><a href="#GetDotenvCliConfig">GetDotenvCliConfig</a> : <code>Object</code></dt>
149
- <dd><p>GetDotenv CLI Config type</p>
150
- </dd>
151
- <dt><a href="#OptionsType">OptionsType</a> : <code>Object</code></dt>
152
- <dd><p>get-dotenv options type</p>
153
- </dd>
154
153
  </dl>
155
154
 
156
- <a name="getCli"></a>
157
-
158
- ## getCli ⇒ <code>object</code>
159
- Generate a CLI for get-dotenv.
160
-
161
- **Kind**: global constant
162
- **Returns**: <code>object</code> - The CLI command.
163
-
164
- | Param | Type | Description |
165
- | --- | --- | --- |
166
- | [config] | [<code>GetDotenvCliConfig</code>](#GetDotenvCliConfig) | config object |
167
-
168
155
  <a name="getDotenv"></a>
169
156
 
170
157
  ## getDotenv([options]) ⇒ <code>Promise.&lt;object&gt;</code>
@@ -175,7 +162,7 @@ Asynchronously process dotenv files of the form .env[.<ENV>][.<PRIVATE_TOKEN>]
175
162
 
176
163
  | Param | Type | Description |
177
164
  | --- | --- | --- |
178
- | [options] | [<code>OptionsType</code>](#OptionsType) | options object |
165
+ | [options] | [<code>GetDotenvOptions</code>](#GetDotenvOptions) | options object |
179
166
 
180
167
  <a name="getDotenvSync"></a>
181
168
 
@@ -187,21 +174,57 @@ Synchronously process dotenv files of the form .env[.<ENV>][.<PRIVATETOKEN>]
187
174
 
188
175
  | Param | Type | Description |
189
176
  | --- | --- | --- |
190
- | [options] | [<code>OptionsType</code>](#OptionsType) | options object |
177
+ | [options] | [<code>GetDotenvOptions</code>](#GetDotenvOptions) | options object |
191
178
 
192
- <a name="GetDotenvCliOptions"></a>
179
+ <a name="getDotenvCli"></a>
193
180
 
194
- ## GetDotenvCliOptions : <code>Object</code>
195
- GetDotenv CLI Options type
181
+ ## getDotenvCli([options]) <code>object</code>
182
+ Generate a CLI for get-dotenv.
183
+
184
+ **Kind**: global function
185
+ **Returns**: <code>object</code> - The CLI command.
186
+
187
+ | Param | Type | Description |
188
+ | --- | --- | --- |
189
+ | [options] | <code>object</code> | options object |
190
+ | [options.alias] | <code>string</code> | cli alias (used for cli help) |
191
+ | [options.command] | <code>string</code> | [dotenv-expanded](https://github.com/motdotla/dotenv-expand/blob/master/tests/.env) shell command string |
192
+ | [options.debug] | <code>bool</code> | debug mode |
193
+ | [options.defaultEnv] | <code>string</code> | default target environment |
194
+ | [options.description] | <code>string</code> | cli description (used for cli help) |
195
+ | [options.dotenvToken] | <code>string</code> | [dotenv-expanded](https://github.com/motdotla/dotenv-expand/blob/master/tests/.env) token indicating a dotenv file |
196
+ | [options.dynamicPath] | <code>string</code> | path to file exporting an object keyed to dynamic variable functions |
197
+ | [options.excludeDynamic] | <code>bool</code> | exclude dynamic dotenv variables |
198
+ | [options.excludeEnv] | <code>bool</code> | exclude environment-specific dotenv variables |
199
+ | [options.excludeGlobal] | <code>bool</code> | exclude global dotenv variables |
200
+ | [options.excludePrivate] | <code>bool</code> | exclude private dotenv variables |
201
+ | [options.excludePublic] | <code>bool</code> | exclude public dotenv variables |
202
+ | [options.loadProcess] | <code>bool</code> | load variables to process.env |
203
+ | [options.log] | <code>bool</code> | log result to console |
204
+ | [options.logger] | <code>function</code> | logger function |
205
+ | [options.outputPath] | <code>string</code> | consolidated output file, [dotenv-expanded](https://github.com/motdotla/dotenv-expand/blob/master/tests/.env) using loaded env vars |
206
+ | [options.paths] | <code>string</code> | [dotenv-expanded](https://github.com/motdotla/dotenv-expand/blob/master/tests/.env) delimited list of input directory paths |
207
+ | [options.pathsDelimiter] | <code>string</code> | paths delimiter string |
208
+ | [options.pathsDelimiterPattern] | <code>string</code> | paths delimiter regex pattern |
209
+ | [config.preHook] | [<code>GetDotenvPreHookCallback</code>](#GetDotenvPreHookCallback) | transforms cli options & executes side effects |
210
+ | [options.privateToken] | <code>string</code> | [dotenv-expanded](https://github.com/motdotla/dotenv-expand/blob/master/tests/.env) token indicating private variables |
211
+ | [config.postHook] | [<code>GetDotenvPostHookCallback</code>](#GetDotenvPostHookCallback) | executes side effects within getdotenv context |
212
+ | [options.vars] | <code>string</code> | [dotenv-expanded](https://github.com/motdotla/dotenv-expand/blob/master/tests/.env) delimited list of explicit environment variable key-value pairs |
213
+ | [options.varsAssignor] | <code>string</code> | variable key-value assignor string |
214
+ | [options.varsAssignorPattern] | <code>string</code> | variable key-value assignor regex pattern |
215
+ | [options.varsDelimiter] | <code>string</code> | variable key-value pair delimiter string |
216
+ | [options.varsDelimiterPattern] | <code>string</code> | variable key-value pair delimiter regex pattern |
217
+
218
+ <a name="GetDotenvOptions"></a>
219
+
220
+ ## GetDotenvOptions : <code>Object</code>
221
+ get-dotenv options type
196
222
 
197
223
  **Kind**: global typedef
198
224
  **Properties**
199
225
 
200
226
  | Name | Type | Description |
201
227
  | --- | --- | --- |
202
- | [cliInvocation] | <code>string</code> | cli invocation string (used for cli help) |
203
- | [debug] | <code>bool</code> | debug mode |
204
- | [defaultEnv] | <code>string</code> | default target environment |
205
228
  | [dotenvToken] | <code>string</code> | token indicating a dotenv file |
206
229
  | [dynamicPath] | <code>string</code> | path to file exporting an object keyed to dynamic variable functions |
207
230
  | [env] | <code>string</code> | target environment |
@@ -210,24 +233,25 @@ GetDotenv CLI Options type
210
233
  | [excludeGlobal] | <code>bool</code> | exclude global & dynamic variables |
211
234
  | [excludePrivate] | <code>bool</code> | exclude private variables |
212
235
  | [excludePublic] | <code>bool</code> | exclude public variables |
213
- | [log] | <code>bool</code> | log result to console |
236
+ | [loadProcess] | <code>bool</code> | load dotenv to process.env |
237
+ | [log] | <code>bool</code> | log result to logger |
214
238
  | [logger] | <code>function</code> | logger function |
215
239
  | [outputPath] | <code>string</code> | if populated, writes consolidated .env file to this path (follows [dotenv-expand rules](https://github.com/motdotla/dotenv-expand/blob/master/tests/.env)) |
216
- | [paths] | <code>string</code> | space-delimited list of input directory paths |
217
- | [privateToken] | <code>string</code> | token indicating private variables. |
218
- | [suppressDotenv] | <code>bool</code> | suppress dotenv loading |
240
+ | [paths] | <code>Array.&lt;string&gt;</code> | array of input directory paths |
241
+ | [privateToken] | <code>string</code> | token indicating private variables |
242
+ | [vars] | <code>object</code> | explicit variables to include |
219
243
 
220
244
  <a name="GetDotenvPreHookCallback"></a>
221
245
 
222
- ## GetDotenvPreHookCallback ⇒ [<code>GetDotenvCliOptions</code>](#GetDotenvCliOptions)
246
+ ## GetDotenvPreHookCallback ⇒ <code>GetDotenvCliOptions</code>
223
247
  GetDotenv CLI Pre-hook Callback type. Transforms inbound options & executes side effects.
224
248
 
225
249
  **Kind**: global typedef
226
- **Returns**: [<code>GetDotenvCliOptions</code>](#GetDotenvCliOptions) - transformed GetDotenv CLI Options object (undefined return value is ignored)
250
+ **Returns**: <code>GetDotenvCliOptions</code> - transformed GetDotenv CLI Options object (undefined return value is ignored)
227
251
 
228
252
  | Param | Type | Description |
229
253
  | --- | --- | --- |
230
- | options | [<code>GetDotenvCliOptions</code>](#GetDotenvCliOptions) | inbound GetDotenv CLI Options object |
254
+ | options | <code>GetDotenvCliOptions</code> | inbound GetDotenv CLI Options object |
231
255
 
232
256
  <a name="GetDotenvPostHookCallback"></a>
233
257
 
@@ -238,50 +262,8 @@ GetDotenv CLI Post-hook Callback type. Executes side effects within getdotenv co
238
262
 
239
263
  | Param | Type | Description |
240
264
  | --- | --- | --- |
241
- | options | [<code>GetDotenvCliOptions</code>](#GetDotenvCliOptions) | GetDotenv CLI Options object |
242
265
  | dotenv | <code>object</code> | dotenv object |
243
266
 
244
- <a name="GetDotenvCliConfig"></a>
245
-
246
- ## GetDotenvCliConfig : <code>Object</code>
247
- GetDotenv CLI Config type
248
-
249
- **Kind**: global typedef
250
- **Properties**
251
-
252
- | Name | Type | Description |
253
- | --- | --- | --- |
254
- | [config] | <code>object</code> | config options |
255
- | [config.defaultOptions] | [<code>GetDotenvCliOptions</code>](#GetDotenvCliOptions) | default options |
256
- | [config.preHook] | [<code>GetDotenvPreHookCallback</code>](#GetDotenvPreHookCallback) | transforms inbound options & executes side effects |
257
- | [config.postHook] | [<code>GetDotenvPostHookCallback</code>](#GetDotenvPostHookCallback) | executes side effects within getdotenv context |
258
-
259
- <a name="OptionsType"></a>
260
-
261
- ## OptionsType : <code>Object</code>
262
- get-dotenv options type
263
-
264
- **Kind**: global typedef
265
- **Properties**
266
-
267
- | Name | Type | Description |
268
- | --- | --- | --- |
269
- | [dotenvToken] | <code>string</code> | token indicating a dotenv file |
270
- | [dynamicPath] | <code>string</code> | path to file exporting an object keyed to dynamic variable functions |
271
- | [env] | <code>string</code> | target environment |
272
- | [excludeDynamic] | <code>bool</code> | exclude dynamic variables |
273
- | [excludeEnv] | <code>bool</code> | exclude environment-specific variables |
274
- | [excludeGlobal] | <code>bool</code> | exclude global & dynamic variables |
275
- | [excludePrivate] | <code>bool</code> | exclude private variables |
276
- | [excludePublic] | <code>bool</code> | exclude public variables |
277
- | [loadProcess] | <code>bool</code> | load dotenv to process.env |
278
- | [log] | <code>bool</code> | log result to logger |
279
- | [logger] | <code>function</code> | logger function |
280
- | [outputPath] | <code>string</code> | if populated, writes consolidated .env file to this path (follows [dotenv-expand rules](https://github.com/motdotla/dotenv-expand/blob/master/tests/.env)) |
281
- | [paths] | <code>Array.&lt;string&gt;</code> | array of input directory paths |
282
- | [privateToken] | <code>string</code> | token indicating private variables |
283
- | [vars] | <code>object</code> | explicit variables to include |
284
-
285
267
 
286
268
  ---
287
269
 
@@ -1,8 +1,8 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  // lib imports
4
- import { getCli } from '../../lib/getCli.js';
4
+ import { getDotenvCli } from '../../lib/getDotenvCli.js';
5
5
 
6
- const cli = getCli();
6
+ const cli = getDotenvCli();
7
7
 
8
8
  await cli.parseAsync();
@@ -6,20 +6,25 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.getDotenvSync = exports.getDotenv = void 0;
7
7
  var _dotenvExpand = require("dotenv-expand");
8
8
  var _fsExtra = _interopRequireDefault(require("fs-extra"));
9
+ var _lodash = _interopRequireDefault(require("lodash.pickby"));
9
10
  var _path = _interopRequireDefault(require("path"));
10
11
  var _nanoid = require("nanoid");
11
- var _dotenvDefaults = require("./dotenvDefaults.js");
12
+ var _options = require("./options.js");
12
13
  var _readDotenv = require("./readDotenv.js");
13
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
15
  // npm imports
15
16
 
16
17
  // lib imports
17
18
 
19
+ const pruneVars = (getdotenvDefaultOptions, options) => (0, _lodash.default)({
20
+ ...(getdotenvDefaultOptions.vars ?? {}),
21
+ ...(options.vars ?? {})
22
+ }, v => v === null || v === void 0 ? void 0 : v.length);
23
+
18
24
  /**
19
25
  * get-dotenv options type
20
26
  *
21
- * @typedef {Object} OptionsType
22
- *
27
+ * @typedef {Object} GetDotenvOptions
23
28
  * @property {string} [dotenvToken] - token indicating a dotenv file
24
29
  * @property {string} [dynamicPath] - path to file exporting an object keyed to dynamic variable functions
25
30
  * @property {string} [env] - target environment
@@ -43,7 +48,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
43
48
  * @async
44
49
  * @function getDotenv
45
50
  *
46
- * @param {OptionsType} [options] - options object
51
+ * @param {GetDotenvOptions} [options] - options object
47
52
  *
48
53
  * @returns {Promise<object>} The combined parsed dotenv object.
49
54
  */
@@ -52,8 +57,8 @@ const getDotenv = async function () {
52
57
  // Apply defaults.
53
58
  let {
54
59
  dotenvToken,
55
- env,
56
60
  dynamicPath,
61
+ env,
57
62
  excludeDynamic,
58
63
  excludeEnv,
59
64
  excludeGlobal,
@@ -61,15 +66,15 @@ const getDotenv = async function () {
61
66
  excludePublic,
62
67
  loadProcess,
63
68
  log,
64
- logger,
69
+ logger = console.log,
65
70
  outputPath,
66
71
  paths,
67
- privateToken,
68
- vars = {}
72
+ privateToken
69
73
  } = {
70
- ..._dotenvDefaults.dotenvDefaults,
74
+ ..._options.getdotenvDefaultOptions,
71
75
  ...options
72
76
  };
77
+ const vars = pruneVars(_options.getdotenvDefaultOptions, options);
73
78
 
74
79
  // Read .env files.
75
80
  const loaded = await paths.reduce(async (e, p) => {
@@ -101,7 +106,7 @@ const getDotenv = async function () {
101
106
  });
102
107
 
103
108
  // Process dynamic variables.
104
- if (dynamicPath && !excludeDynamic) {
109
+ if (dynamicPath && !excludeDynamic && (await _fsExtra.default.exists(dynamicPath))) {
105
110
  const dynamic = new Function(`return ${(await _fsExtra.default.readFile(dynamicPath)).toString()}`)()(dotenv);
106
111
  Object.keys(dynamic).forEach(key => {
107
112
  Object.assign(dotenv, {
@@ -129,8 +134,8 @@ const getDotenv = async function () {
129
134
  if (loadProcess) Object.assign(process.env, dotenv, {
130
135
  getdotenvOptions: JSON.stringify({
131
136
  dotenvToken,
132
- env,
133
137
  dynamicPath,
138
+ env,
134
139
  excludeDynamic,
135
140
  excludeEnv,
136
141
  excludeGlobal,
@@ -151,7 +156,7 @@ const getDotenv = async function () {
151
156
  *
152
157
  * @function getDotenvSync
153
158
  *
154
- * @param {OptionsType} [options] - options object
159
+ * @param {GetDotenvOptions} [options] - options object
155
160
  *
156
161
  * @returns {Object} The combined parsed dotenv object.
157
162
  */
@@ -161,8 +166,8 @@ const getDotenvSync = function () {
161
166
  // Apply defaults.
162
167
  let {
163
168
  dotenvToken,
164
- env,
165
169
  dynamicPath,
170
+ env,
166
171
  excludeDynamic,
167
172
  excludeEnv,
168
173
  excludeGlobal,
@@ -170,14 +175,15 @@ const getDotenvSync = function () {
170
175
  excludePublic,
171
176
  loadProcess,
172
177
  log,
178
+ logger = console.log,
173
179
  outputPath,
174
180
  paths,
175
- privateToken,
176
- vars
181
+ privateToken
177
182
  } = {
178
- ..._dotenvDefaults.dotenvDefaults,
183
+ ..._options.getdotenvDefaultOptions,
179
184
  ...options
180
185
  };
186
+ const vars = pruneVars(_options.getdotenvDefaultOptions, options);
181
187
 
182
188
  // Read .env files.
183
189
  const loaded = paths.reduce((e, p) => {
@@ -208,7 +214,7 @@ const getDotenvSync = function () {
208
214
  });
209
215
 
210
216
  // Process dynamic variables.
211
- if (dynamicPath && !excludeDynamic) {
217
+ if (dynamicPath && !excludeDynamic && _fsExtra.default.existsSync(dynamicPath)) {
212
218
  const dynamic = new Function(`return ${_fsExtra.default.readFileSync(dynamicPath).toString()}`)()(dotenv);
213
219
  Object.keys(dynamic).forEach(key => {
214
220
  Object.assign(dotenv, {
@@ -230,7 +236,7 @@ const getDotenvSync = function () {
230
236
  }
231
237
 
232
238
  // Log result.
233
- if (log) console.log(dotenv);
239
+ if (log) logger(dotenv);
234
240
 
235
241
  // Load process.env.
236
242
  if (loadProcess) Object.assign(process.env, dotenv, {