@karmaniverous/get-dotenv 3.1.2 → 3.1.4

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.
@@ -131,23 +131,7 @@ const getDotenv = async function () {
131
131
  if (log) logger(dotenv);
132
132
 
133
133
  // Load process.env.
134
- if (loadProcess) Object.assign(process.env, dotenv, {
135
- getdotenvOptions: JSON.stringify({
136
- dotenvToken,
137
- dynamicPath,
138
- env,
139
- excludeDynamic,
140
- excludeEnv,
141
- excludeGlobal,
142
- excludePrivate,
143
- excludePublic,
144
- loadProcess,
145
- log,
146
- outputPath,
147
- paths,
148
- privateToken
149
- })
150
- });
134
+ if (loadProcess) Object.assign(process.env, dotenv);
151
135
  return dotenv;
152
136
  };
153
137
 
@@ -239,23 +223,7 @@ const getDotenvSync = function () {
239
223
  if (log) logger(dotenv);
240
224
 
241
225
  // Load process.env.
242
- if (loadProcess) Object.assign(process.env, dotenv, {
243
- getdotenvOptions: JSON.stringify({
244
- dotenvToken,
245
- dynamicPath,
246
- env,
247
- excludeDynamic,
248
- excludeEnv,
249
- excludeGlobal,
250
- excludePrivate,
251
- excludePublic,
252
- loadProcess,
253
- log,
254
- outputPath,
255
- paths,
256
- privateToken
257
- })
258
- });
226
+ if (loadProcess) Object.assign(process.env, dotenv);
259
227
  return dotenv;
260
228
  };
261
229
  exports.getDotenvSync = getDotenvSync;
@@ -71,7 +71,7 @@ const getDotenvCli = function () {
71
71
  postHook,
72
72
  ...cliOptionsCustom
73
73
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
74
- let {
74
+ const {
75
75
  alias,
76
76
  command,
77
77
  debug,
@@ -92,7 +92,6 @@ const getDotenvCli = function () {
92
92
  pathsDelimiter,
93
93
  pathsDelimiterPattern,
94
94
  privateToken,
95
- vars,
96
95
  varsAssignor,
97
96
  varsAssignorPattern,
98
97
  varsDelimiter,
@@ -103,7 +102,7 @@ const getDotenvCli = function () {
103
102
  ..._options.cliDefaultOptionsLocal
104
103
  };
105
104
  const excludeAll = excludeDynamic && (excludeEnv && excludeGlobal || excludePrivate && excludePublic);
106
- return new _commander.Command().name(alias).description(description).enablePositionalOptions().passThroughOptions().option('-e, --env <string>', 'target environment', _dotenvExpand.dotenvExpand, env).option('-v, --vars <string>', `dotenv-expanded delimited key-value pairs: ${[['KEY1', 'VAL1'], ['KEY2', 'VAL2']].map(v => v.join(varsAssignor)).join(varsDelimiter)}`, _dotenvExpand.dotenvExpand, vars).option('-c, --command <string>', 'dotenv-expanded shell command string', _dotenvExpand.dotenvExpand, command).option('-o, --output-path <string>', 'consolidated output file, follows dotenv-expand rules using loaded env vars', _dotenvExpand.dotenvExpand, outputPath).addOption(new _commander.Option('-p, --load-process', `load variables to process.env ON${loadProcess ? ' (default)' : ''}`).conflicts('loadProcessOff')).addOption(new _commander.Option('-P, --load-process-off', `load variables to process.env OFF${!loadProcess ? ' (default)' : ''}`).conflicts('loadProcess')).addOption(new _commander.Option('-a, --exclude-all', `exclude all dotenv variables from loading ON${excludeAll ? ' (default)' : ''}`).conflicts('excludeAllOff')).addOption(new _commander.Option('-A, --exclude-all-off', `exclude all dotenv variables from loading OFF${!excludeAll ? ' (default)' : ''}`).conflicts('excludeAll')).addOption(new _commander.Option('-z, --exclude-dynamic', `exclude dynamic dotenv variables from loading ON${excludeDynamic ? ' (default)' : ''}`).conflicts('excludeDynamicOff')).addOption(new _commander.Option('-Z, --exclude-dynamic-off', `exclude dynamic dotenv variables from loading OFF${!excludeDynamic ? ' (default)' : ''}`).conflicts('excludeDynamic')).addOption(new _commander.Option('-n, --exclude-env', `exclude environment-specific dotenv variables from loading${excludeEnv ? ' (default)' : ''}`).conflicts('excludeEnvOff')).addOption(new _commander.Option('-N, --exclude-env-off', `exclude environment-specific dotenv variables from loading OFF${!excludeEnv ? ' (default)' : ''}`).conflicts('excludeEnv')).addOption(new _commander.Option('-g, --exclude-global', `exclude global dotenv variables from loading ON${excludeGlobal ? ' (default)' : ''}`).conflicts('excludeGlobalOff')).addOption(new _commander.Option('-G, --exclude-global-off', `exclude global dotenv variables from loading OFF${!excludeGlobal ? ' (default)' : ''}`).conflicts('excludeGlobal')).addOption(new _commander.Option('-r, --exclude-private', `exclude private dotenv variables from loading ON${excludePrivate ? ' (default)' : ''}`).conflicts('excludePrivateOff')).addOption(new _commander.Option('-R, --exclude-private-off', `exclude private dotenv variables from loading OFF${!excludePrivate ? ' (default)' : ''}`).conflicts('excludePrivate')).addOption(new _commander.Option('-u, --exclude-public', `exclude public dotenv variables from loading ON${excludePublic ? ' (default)' : ''}`).conflicts('excludePublicOff')).addOption(new _commander.Option('-U, --exclude-public-off', `exclude public dotenv variables from loading OFF${!excludePublic ? ' (default)' : ''}`).conflicts('excludePublic')).addOption(new _commander.Option('-l, --log', `console log loaded variables ON${log ? ' (default)' : ''}`).conflicts('logOff')).addOption(new _commander.Option('-L, --log-off', `console log loaded variables OFF${!log ? ' (default)' : ''}`).conflicts('log')).addOption(new _commander.Option('-d, --debug', `debug mode ON${debug ? ' (default)' : ''}`).conflicts('debugOff')).addOption(new _commander.Option('-D, --debug-off', `debug mode OFF${!debug ? ' (default)' : ''}`).conflicts('debug')).option('--default-env <string>', 'default target environment', _dotenvExpand.dotenvExpand, defaultEnv).option('--dotenv-token <string>', 'dotenv-expanded token indicating a dotenv file', _dotenvExpand.dotenvExpand, dotenvToken).option('--dynamic-path <string>', 'dynamic variables path', _dotenvExpand.dotenvExpand, dynamicPath).option('--paths <string>', 'dotenv-expanded delimited list of paths to dotenv directory', _dotenvExpand.dotenvExpand, paths).option('--paths-delimiter <string>', 'paths delimiter string', pathsDelimiter).option('--paths-delimiter-pattern <string>', 'paths delimiter regex pattern', pathsDelimiterPattern).option('--private-token <string>', 'dotenv-expanded token indicating private variables', _dotenvExpand.dotenvExpand, privateToken).option('--vars-delimiter <string>', 'vars delimiter string', varsDelimiter).option('--vars-delimiter-pattern <string>', 'vars delimiter regex pattern', varsDelimiterPattern).option('--vars-assignor <string>', 'vars assignment operator string', varsAssignor).option('--vars-assignor-pattern <string>', 'vars assignment operator regex pattern', varsAssignorPattern).addCommand(new _commander.Command().name('cmd').description('execute shell command string (default command)').configureHelp({
105
+ return new _commander.Command().name(alias).description(description).enablePositionalOptions().passThroughOptions().option('-e, --env <string>', 'target environment', _dotenvExpand.dotenvExpand, env).option('-v, --vars <string>', `dotenv-expanded delimited key-value pairs: ${[['KEY1', 'VAL1'], ['KEY2', 'VAL2']].map(v => v.join(varsAssignor)).join(varsDelimiter)}`, _dotenvExpand.dotenvExpand).option('-c, --command <string>', 'dotenv-expanded shell command string', _dotenvExpand.dotenvExpand, command).option('-o, --output-path <string>', 'consolidated output file, follows dotenv-expand rules using loaded env vars', _dotenvExpand.dotenvExpand, outputPath).addOption(new _commander.Option('-p, --load-process', `load variables to process.env ON${loadProcess ? ' (default)' : ''}`).conflicts('loadProcessOff')).addOption(new _commander.Option('-P, --load-process-off', `load variables to process.env OFF${!loadProcess ? ' (default)' : ''}`).conflicts('loadProcess')).addOption(new _commander.Option('-a, --exclude-all', `exclude all dotenv variables from loading ON${excludeAll ? ' (default)' : ''}`).conflicts('excludeAllOff')).addOption(new _commander.Option('-A, --exclude-all-off', `exclude all dotenv variables from loading OFF${!excludeAll ? ' (default)' : ''}`).conflicts('excludeAll')).addOption(new _commander.Option('-z, --exclude-dynamic', `exclude dynamic dotenv variables from loading ON${excludeDynamic ? ' (default)' : ''}`).conflicts('excludeDynamicOff')).addOption(new _commander.Option('-Z, --exclude-dynamic-off', `exclude dynamic dotenv variables from loading OFF${!excludeDynamic ? ' (default)' : ''}`).conflicts('excludeDynamic')).addOption(new _commander.Option('-n, --exclude-env', `exclude environment-specific dotenv variables from loading${excludeEnv ? ' (default)' : ''}`).conflicts('excludeEnvOff')).addOption(new _commander.Option('-N, --exclude-env-off', `exclude environment-specific dotenv variables from loading OFF${!excludeEnv ? ' (default)' : ''}`).conflicts('excludeEnv')).addOption(new _commander.Option('-g, --exclude-global', `exclude global dotenv variables from loading ON${excludeGlobal ? ' (default)' : ''}`).conflicts('excludeGlobalOff')).addOption(new _commander.Option('-G, --exclude-global-off', `exclude global dotenv variables from loading OFF${!excludeGlobal ? ' (default)' : ''}`).conflicts('excludeGlobal')).addOption(new _commander.Option('-r, --exclude-private', `exclude private dotenv variables from loading ON${excludePrivate ? ' (default)' : ''}`).conflicts('excludePrivateOff')).addOption(new _commander.Option('-R, --exclude-private-off', `exclude private dotenv variables from loading OFF${!excludePrivate ? ' (default)' : ''}`).conflicts('excludePrivate')).addOption(new _commander.Option('-u, --exclude-public', `exclude public dotenv variables from loading ON${excludePublic ? ' (default)' : ''}`).conflicts('excludePublicOff')).addOption(new _commander.Option('-U, --exclude-public-off', `exclude public dotenv variables from loading OFF${!excludePublic ? ' (default)' : ''}`).conflicts('excludePublic')).addOption(new _commander.Option('-l, --log', `console log loaded variables ON${log ? ' (default)' : ''}`).conflicts('logOff')).addOption(new _commander.Option('-L, --log-off', `console log loaded variables OFF${!log ? ' (default)' : ''}`).conflicts('log')).addOption(new _commander.Option('-d, --debug', `debug mode ON${debug ? ' (default)' : ''}`).conflicts('debugOff')).addOption(new _commander.Option('-D, --debug-off', `debug mode OFF${!debug ? ' (default)' : ''}`).conflicts('debug')).option('--default-env <string>', 'default target environment', _dotenvExpand.dotenvExpand, defaultEnv).option('--dotenv-token <string>', 'dotenv-expanded token indicating a dotenv file', _dotenvExpand.dotenvExpand, dotenvToken).option('--dynamic-path <string>', 'dynamic variables path', _dotenvExpand.dotenvExpand, dynamicPath).option('--paths <string>', 'dotenv-expanded delimited list of paths to dotenv directory', _dotenvExpand.dotenvExpand, paths).option('--paths-delimiter <string>', 'paths delimiter string', pathsDelimiter).option('--paths-delimiter-pattern <string>', 'paths delimiter regex pattern', pathsDelimiterPattern).option('--private-token <string>', 'dotenv-expanded token indicating private variables', _dotenvExpand.dotenvExpand, privateToken).option('--vars-delimiter <string>', 'vars delimiter string', varsDelimiter).option('--vars-delimiter-pattern <string>', 'vars delimiter regex pattern', varsDelimiterPattern).option('--vars-assignor <string>', 'vars assignment operator string', varsAssignor).option('--vars-assignor-pattern <string>', 'vars assignment operator regex pattern', varsAssignorPattern).addCommand(new _commander.Command().name('cmd').description('execute shell command string (default command)').configureHelp({
107
106
  showGlobalOptions: true
108
107
  }).enablePositionalOptions().passThroughOptions().action(async (options, _ref) => {
109
108
  let {
@@ -158,7 +157,7 @@ const getDotenvCli = function () {
158
157
  }
159
158
 
160
159
  // Get getdotenv options from parent command.
161
- const parentGetdotenvOptions = process.env['getdotenvOptions'] ? JSON.parse(process.env['getdotenvOptions']) : {};
160
+ const parentGetdotenvOptions = process.env.getdotenvOptions ? JSON.parse(process.env.getdotenvOptions) : {};
162
161
  const cliGetdotenvOptions = (0, _options.cli2getdotenvOptions)(cliOptions);
163
162
  const getdotenvOptions = {
164
163
  ...parentGetdotenvOptions,
@@ -184,8 +183,12 @@ const getDotenvCli = function () {
184
183
 
185
184
  // Execute shell command.
186
185
  if (command) await (0, _execa.execaCommand)(command.replace(/ /g, '\\ '), {
187
- stdio: 'inherit',
188
- shell: true
186
+ env: {
187
+ ...process.env,
188
+ getdotenvOptions: JSON.stringify(getdotenvOptions)
189
+ },
190
+ shell: true,
191
+ stdio: 'inherit'
189
192
  });
190
193
  });
191
194
  };
package/lib/getDotenv.js CHANGED
@@ -148,24 +148,7 @@ export const getDotenv = async (options = {}) => {
148
148
  if (log) logger(dotenv);
149
149
 
150
150
  // Load process.env.
151
- if (loadProcess)
152
- Object.assign(process.env, dotenv, {
153
- getdotenvOptions: JSON.stringify({
154
- dotenvToken,
155
- dynamicPath,
156
- env,
157
- excludeDynamic,
158
- excludeEnv,
159
- excludeGlobal,
160
- excludePrivate,
161
- excludePublic,
162
- loadProcess,
163
- log,
164
- outputPath,
165
- paths,
166
- privateToken,
167
- }),
168
- });
151
+ if (loadProcess) Object.assign(process.env, dotenv);
169
152
 
170
153
  return dotenv;
171
154
  };
@@ -276,24 +259,7 @@ export const getDotenvSync = (options = {}) => {
276
259
  if (log) logger(dotenv);
277
260
 
278
261
  // Load process.env.
279
- if (loadProcess)
280
- Object.assign(process.env, dotenv, {
281
- getdotenvOptions: JSON.stringify({
282
- dotenvToken,
283
- dynamicPath,
284
- env,
285
- excludeDynamic,
286
- excludeEnv,
287
- excludeGlobal,
288
- excludePrivate,
289
- excludePublic,
290
- loadProcess,
291
- log,
292
- outputPath,
293
- paths,
294
- privateToken,
295
- }),
296
- });
262
+ if (loadProcess) Object.assign(process.env, dotenv);
297
263
 
298
264
  return dotenv;
299
265
  };
@@ -68,7 +68,7 @@ export const getDotenvCli = ({
68
68
  postHook,
69
69
  ...cliOptionsCustom
70
70
  } = {}) => {
71
- let {
71
+ const {
72
72
  alias,
73
73
  command,
74
74
  debug,
@@ -89,7 +89,6 @@ export const getDotenvCli = ({
89
89
  pathsDelimiter,
90
90
  pathsDelimiterPattern,
91
91
  privateToken,
92
- vars,
93
92
  varsAssignor,
94
93
  varsAssignorPattern,
95
94
  varsDelimiter,
@@ -118,8 +117,7 @@ export const getDotenvCli = ({
118
117
  ]
119
118
  .map((v) => v.join(varsAssignor))
120
119
  .join(varsDelimiter)}`,
121
- dotenvExpand,
122
- vars
120
+ dotenvExpand
123
121
  )
124
122
  .option(
125
123
  '-c, --command <string>',
@@ -418,8 +416,8 @@ export const getDotenvCli = ({
418
416
  }
419
417
 
420
418
  // Get getdotenv options from parent command.
421
- const parentGetdotenvOptions = process.env['getdotenvOptions']
422
- ? JSON.parse(process.env['getdotenvOptions'])
419
+ const parentGetdotenvOptions = process.env.getdotenvOptions
420
+ ? JSON.parse(process.env.getdotenvOptions)
423
421
  : {};
424
422
 
425
423
  const cliGetdotenvOptions = cli2getdotenvOptions(cliOptions);
@@ -448,8 +446,12 @@ export const getDotenvCli = ({
448
446
  // Execute shell command.
449
447
  if (command)
450
448
  await execaCommand(command.replace(/ /g, '\\ '), {
451
- stdio: 'inherit',
449
+ env: {
450
+ ...process.env,
451
+ getdotenvOptions: JSON.stringify(getdotenvOptions),
452
+ },
452
453
  shell: true,
454
+ stdio: 'inherit',
453
455
  });
454
456
  });
455
457
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "bin": {
4
4
  "getdotenv": "bin/getdotenv/index.js"
5
5
  },
6
- "version": "3.1.2",
6
+ "version": "3.1.4",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },