@karmaniverous/get-dotenv 3.0.5 → 3.0.6

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
@@ -13,7 +13,7 @@ Load environment variables with a cascade of environment-aware dotenv files. You
13
13
 
14
14
  `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
15
 
16
- The command-line version populates `process.env` from your dotenv files (you can also specify values inline) and can then execute a shell command within that context. The executing shell is configurable. Any child `getdotenv` instances will inherit as defaults the parent shell's environment and optionally its `getdotenv` settings.
16
+ The command-line version populates `process.env` from your dotenv files (you can also specify values inline) and can then execute a shell command within that context. Any child `getdotenv` instances will inherit as defaults the parent shell's environment and optionally its `getdotenv` settings.
17
17
 
18
18
  You can always use `getdotenv` directly on the command line, but its REAL power comes into play when you use it as the foundation of your own CLI. This lets you set defaults globally and configure pre- and post-hooks that mutate your `getdotenv` context and do useful things like grab an AWS session from your dev environment and add it to the command execution context.
19
19
 
@@ -102,7 +102,6 @@ Options:
102
102
  -L, --log-off console log extracted variables OFF (default)
103
103
  -x, --suppress-dotenv suppress dotenv loading (default: false)
104
104
  -c, --command <string> shell command string
105
- -s, --shell <string> execa shell option
106
105
  --dotenv-token <string> token indicating a dotenv file (default: ".env")
107
106
  --private-token <string> token indicating private variables (default: "local")
108
107
  -D, --debug debug mode
@@ -216,7 +215,6 @@ GetDotenv CLI Options type
216
215
  | [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)) |
217
216
  | [paths] | <code>string</code> | space-delimited list of input directory paths |
218
217
  | [privateToken] | <code>string</code> | token indicating private variables. |
219
- | [shell] | <code>string</code> | execa shell option |
220
218
  | [suppressDotenv] | <code>bool</code> | suppress dotenv loading |
221
219
 
222
220
  <a name="GetDotenvPreHookCallback"></a>
@@ -39,7 +39,6 @@ const booleanExpand = value => (0, _boolean.boolean)((0, _dotenvExpand.dotenvExp
39
39
  * @property {string} [outputPath] - if populated, writes consolidated .env file to this path (follows {@link https://github.com/motdotla/dotenv-expand/blob/master/tests/.env dotenv-expand rules})
40
40
  * @property {string} [paths] - space-delimited list of input directory paths
41
41
  * @property {string} [privateToken] - token indicating private variables.
42
- * @property {string} [shell] - execa shell option
43
42
  * @property {bool} [suppressDotenv] - suppress dotenv loading
44
43
  */
45
44
 
@@ -100,7 +99,6 @@ const getCli = function () {
100
99
  paths,
101
100
  pathsDelimiter = '\\s+',
102
101
  privateToken,
103
- shell,
104
102
  suppressDotenv,
105
103
  vars,
106
104
  varsAssignor = '=',
@@ -110,16 +108,15 @@ const getCli = function () {
110
108
  ...defaultOptions
111
109
  };
112
110
  if (Array.isArray(paths)) paths = paths.join(' ');
113
- return new _commander.Command().name(cliInvocation).description('Base CLI. All options except delimiters follow dotenv-expand rules.').enablePositionalOptions().passThroughOptions().option('-e, --env <string>', 'target environment', _dotenvExpand.dotenvExpand, env).option('--default-env <string>', 'default target environment', _dotenvExpand.dotenvExpand, defaultEnv).option('-p, --paths <string>', 'delimited list of paths to dotenv directory', _dotenvExpand.dotenvExpand, paths).option('--paths-delimiter <string>', 'regex paths delimiter', pathsDelimiter).option('-v, --vars <string>', 'delimited list KEY=VALUE pairs', _dotenvExpand.dotenvExpand, vars).option('--vars-delimiter <string>', 'regex vars delimiter', varsDelimiter).option('--vars-assignor <string>', 'regex vars assignment operator', varsAssignor).option('-y, --dynamic-path <string>', 'dynamic variables path', _dotenvExpand.dotenvExpand, dynamicPath).option('-o, --output-path <string>', 'consolidated output file, follows dotenv-expand rules using loaded env vars', _dotenvExpand.dotenvExpand, outputPath).addOption(new _commander.Option('-n, --exclude-env', `exclude environment-specific variables${excludeEnv ? ' (default)' : ''}`).conflicts('excludeEnvOff')).addOption(new _commander.Option('-N, --exclude-env-off', `exclude environment-specific variables OFF${!excludeEnv ? ' (default)' : ''}`).conflicts('excludeEnv')).addOption(new _commander.Option('-g, --exclude-global', `exclude global variables${excludeGlobal ? ' (default)' : ''}`).conflicts('excludeGlobalOff')).addOption(new _commander.Option('-G, --exclude-global-off', `exclude global variables OFF${!excludeGlobal ? ' (default)' : ''}`).conflicts('excludeGlobal')).addOption(new _commander.Option('-r, --exclude-private', `exclude private variables${excludePrivate ? ' (default)' : ''}`).conflicts('excludePrivateOff')).addOption(new _commander.Option('-R, --exclude-private-off', `exclude private variables OFF${!excludePrivate ? ' (default)' : ''}`).conflicts('excludePrivate')).addOption(new _commander.Option('-u, --exclude-public', `exclude public variables${excludePublic ? ' (default)' : ''}`).conflicts('excludePublicOff')).addOption(new _commander.Option('-U, --exclude-public-off', `exclude public variables OFF${!excludePublic ? ' (default)' : ''}`).conflicts('excludePublic')).addOption(new _commander.Option('-z, --exclude-dynamic', `exclude dynamic variables${excludeDynamic ? ' (default)' : ''}`).conflicts('excludeDynamicOff')).addOption(new _commander.Option('-Z, --exclude-dynamic-off', `exclude dynamic variables OFF${!excludeDynamic ? ' (default)' : ''}`).conflicts('excludeDynamic')).addOption(new _commander.Option('-l, --log', `console log extracted variables${log ? ' (default)' : ''}`).conflicts('logOff')).addOption(new _commander.Option('-L, --log-off', `console log extracted variables OFF${!log ? ' (default)' : ''}`).conflicts('log')).option('-x, --suppress-dotenv', 'suppress dotenv loading', booleanExpand, suppressDotenv ?? false).option('-c, --command <string>', 'shell command string', _dotenvExpand.dotenvExpand, command).option('-s, --shell <string>', 'execa shell option', _dotenvExpand.dotenvExpand, shell).option('--dotenv-token <string>', 'token indicating a dotenv file', _dotenvExpand.dotenvExpand, dotenvToken).option('--private-token <string>', 'token indicating private variables', _dotenvExpand.dotenvExpand, privateToken).option('-D, --debug', 'debug mode').addCommand(new _commander.Command().name('cmd').description('execute shell command string (default command)').configureHelp({
111
+ return new _commander.Command().name(cliInvocation).description('Base CLI. All options except delimiters follow dotenv-expand rules.').enablePositionalOptions().passThroughOptions().option('-e, --env <string>', 'target environment', _dotenvExpand.dotenvExpand, env).option('--default-env <string>', 'default target environment', _dotenvExpand.dotenvExpand, defaultEnv).option('-p, --paths <string>', 'delimited list of paths to dotenv directory', _dotenvExpand.dotenvExpand, paths).option('--paths-delimiter <string>', 'regex paths delimiter', pathsDelimiter).option('-v, --vars <string>', 'delimited list KEY=VALUE pairs', _dotenvExpand.dotenvExpand, vars).option('--vars-delimiter <string>', 'regex vars delimiter', varsDelimiter).option('--vars-assignor <string>', 'regex vars assignment operator', varsAssignor).option('-y, --dynamic-path <string>', 'dynamic variables path', _dotenvExpand.dotenvExpand, dynamicPath).option('-o, --output-path <string>', 'consolidated output file, follows dotenv-expand rules using loaded env vars', _dotenvExpand.dotenvExpand, outputPath).addOption(new _commander.Option('-n, --exclude-env', `exclude environment-specific variables${excludeEnv ? ' (default)' : ''}`).conflicts('excludeEnvOff')).addOption(new _commander.Option('-N, --exclude-env-off', `exclude environment-specific variables OFF${!excludeEnv ? ' (default)' : ''}`).conflicts('excludeEnv')).addOption(new _commander.Option('-g, --exclude-global', `exclude global variables${excludeGlobal ? ' (default)' : ''}`).conflicts('excludeGlobalOff')).addOption(new _commander.Option('-G, --exclude-global-off', `exclude global variables OFF${!excludeGlobal ? ' (default)' : ''}`).conflicts('excludeGlobal')).addOption(new _commander.Option('-r, --exclude-private', `exclude private variables${excludePrivate ? ' (default)' : ''}`).conflicts('excludePrivateOff')).addOption(new _commander.Option('-R, --exclude-private-off', `exclude private variables OFF${!excludePrivate ? ' (default)' : ''}`).conflicts('excludePrivate')).addOption(new _commander.Option('-u, --exclude-public', `exclude public variables${excludePublic ? ' (default)' : ''}`).conflicts('excludePublicOff')).addOption(new _commander.Option('-U, --exclude-public-off', `exclude public variables OFF${!excludePublic ? ' (default)' : ''}`).conflicts('excludePublic')).addOption(new _commander.Option('-z, --exclude-dynamic', `exclude dynamic variables${excludeDynamic ? ' (default)' : ''}`).conflicts('excludeDynamicOff')).addOption(new _commander.Option('-Z, --exclude-dynamic-off', `exclude dynamic variables OFF${!excludeDynamic ? ' (default)' : ''}`).conflicts('excludeDynamic')).addOption(new _commander.Option('-l, --log', `console log extracted variables${log ? ' (default)' : ''}`).conflicts('logOff')).addOption(new _commander.Option('-L, --log-off', `console log extracted variables OFF${!log ? ' (default)' : ''}`).conflicts('log')).option('-x, --suppress-dotenv', 'suppress dotenv loading', booleanExpand, suppressDotenv ?? false).option('-c, --command <string>', 'shell command string', _dotenvExpand.dotenvExpand, command).option('--dotenv-token <string>', 'token indicating a dotenv file', _dotenvExpand.dotenvExpand, dotenvToken).option('--private-token <string>', 'token indicating private variables', _dotenvExpand.dotenvExpand, privateToken).option('-D, --debug', 'debug mode').addCommand(new _commander.Command().name('cmd').description('execute shell command string (default command)').configureHelp({
114
112
  showGlobalOptions: true
115
113
  }).enablePositionalOptions().passThroughOptions().action(async (options, _ref) => {
116
114
  let {
117
- args,
118
- parent
115
+ args
119
116
  } = _ref;
120
- if (args.length) await (0, _execa.execaCommand)(args.join(' '), {
117
+ if (args.length) await (0, _execa.execaCommand)(args.join('\\ '), {
121
118
  stdio: 'inherit',
122
- shell: parent.opts().shell
119
+ shell: true
123
120
  });
124
121
  }), {
125
122
  isDefault: true
@@ -193,9 +190,9 @@ const getCli = function () {
193
190
  if (postHook) await postHook(options, dotenv);
194
191
 
195
192
  // Execute shell command.
196
- if (command) await (0, _execa.execaCommand)(command, {
193
+ if (command) await (0, _execa.execaCommand)(command.replace(/ /g, '\\ '), {
197
194
  stdio: 'inherit',
198
- shell
195
+ shell: true
199
196
  });
200
197
  });
201
198
  };
package/lib/getCli.js CHANGED
@@ -32,7 +32,6 @@ const booleanExpand = (value) => boolean(dotenvExpand(value));
32
32
  * @property {string} [outputPath] - if populated, writes consolidated .env file to this path (follows {@link https://github.com/motdotla/dotenv-expand/blob/master/tests/.env dotenv-expand rules})
33
33
  * @property {string} [paths] - space-delimited list of input directory paths
34
34
  * @property {string} [privateToken] - token indicating private variables.
35
- * @property {string} [shell] - execa shell option
36
35
  * @property {bool} [suppressDotenv] - suppress dotenv loading
37
36
  */
38
37
 
@@ -88,7 +87,6 @@ export const getCli = ({ defaultOptions = {}, preHook, postHook } = {}) => {
88
87
  paths,
89
88
  pathsDelimiter = '\\s+',
90
89
  privateToken,
91
- shell,
92
90
  suppressDotenv,
93
91
  vars,
94
92
  varsAssignor = '=',
@@ -237,7 +235,6 @@ export const getCli = ({ defaultOptions = {}, preHook, postHook } = {}) => {
237
235
  dotenvExpand,
238
236
  command
239
237
  )
240
- .option('-s, --shell <string>', 'execa shell option', dotenvExpand, shell)
241
238
  .option(
242
239
  '--dotenv-token <string>',
243
240
  'token indicating a dotenv file',
@@ -258,11 +255,11 @@ export const getCli = ({ defaultOptions = {}, preHook, postHook } = {}) => {
258
255
  .configureHelp({ showGlobalOptions: true })
259
256
  .enablePositionalOptions()
260
257
  .passThroughOptions()
261
- .action(async (options, { args, parent }) => {
258
+ .action(async (options, { args }) => {
262
259
  if (args.length)
263
- await execaCommand(args.join(' '), {
260
+ await execaCommand(args.join('\\ '), {
264
261
  stdio: 'inherit',
265
- shell: parent.opts().shell,
262
+ shell: true,
266
263
  });
267
264
  }),
268
265
  { isDefault: true }
@@ -352,9 +349,9 @@ export const getCli = ({ defaultOptions = {}, preHook, postHook } = {}) => {
352
349
 
353
350
  // Execute shell command.
354
351
  if (command)
355
- await execaCommand(command, {
352
+ await execaCommand(command.replace(/ /g, '\\ '), {
356
353
  stdio: 'inherit',
357
- shell,
354
+ shell: true,
358
355
  });
359
356
  });
360
357
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "bin": {
4
4
  "getdotenv": "bin/getdotenv/index.js"
5
5
  },
6
- "version": "3.0.5",
6
+ "version": "3.0.6",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },