@karmaniverous/get-dotenv 4.1.0 → 4.2.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.
- package/README.md +1 -1
- package/dist/getdotenv.cli.mjs +56 -30
- package/dist/index.cjs +56 -30
- package/dist/index.d.cts +5 -1
- package/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.mjs +56 -30
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -121,7 +121,7 @@ You can also use `getdotenv` from the command line:
|
|
|
121
121
|
# --vars-delimiter-pattern <string> vars delimiter regex pattern
|
|
122
122
|
# --vars-assignor <string> vars assignment operator string (default: "=")
|
|
123
123
|
# --vars-assignor-pattern <string> vars assignment operator regex pattern
|
|
124
|
-
|
|
124
|
+
# -h, --help display help for command
|
|
125
125
|
#
|
|
126
126
|
# Commands:
|
|
127
127
|
# batch [options] Batch shell commands across multiple working directories.
|
package/dist/getdotenv.cli.mjs
CHANGED
|
@@ -25764,6 +25764,7 @@ const defaultGetDotenvCliOptionsGlobal = {
|
|
|
25764
25764
|
paths: './',
|
|
25765
25765
|
pathsDelimiter: ' ',
|
|
25766
25766
|
privateToken: 'local',
|
|
25767
|
+
shellScripts: {},
|
|
25767
25768
|
vars: '',
|
|
25768
25769
|
varsAssignor: '=',
|
|
25769
25770
|
varsDelimiter: ' ',
|
|
@@ -25800,6 +25801,10 @@ const defaultGetDotenvCliOptionsLocal = (fs$a.existsSync(defaultGetDotenvCliOpti
|
|
|
25800
25801
|
const mergeGetDotenvOptions = (target = {}, source = {}) => ({
|
|
25801
25802
|
...source,
|
|
25802
25803
|
...target,
|
|
25804
|
+
shellScripts: {
|
|
25805
|
+
...(source.shellScripts ?? {}),
|
|
25806
|
+
...(target.shellScripts ?? {}),
|
|
25807
|
+
},
|
|
25803
25808
|
vars: _.pickBy({
|
|
25804
25809
|
...(source.vars ?? {}),
|
|
25805
25810
|
...(target.vars ?? {}),
|
|
@@ -25832,6 +25837,10 @@ const getDotenvCliOptions2Options = ({ paths, pathsDelimiter, pathsDelimiterPatt
|
|
|
25832
25837
|
const getDotenvDefaultOptions = getDotenvCliOptions2Options({
|
|
25833
25838
|
...defaultGetDotenvCliOptionsGlobal,
|
|
25834
25839
|
...defaultGetDotenvCliOptionsLocal,
|
|
25840
|
+
shellScripts: {
|
|
25841
|
+
...(defaultGetDotenvCliOptionsGlobal.shellScripts ?? {}),
|
|
25842
|
+
...(defaultGetDotenvCliOptionsLocal.shellScripts ?? {}),
|
|
25843
|
+
},
|
|
25835
25844
|
});
|
|
25836
25845
|
|
|
25837
25846
|
var main$1 = {exports: {}};
|
|
@@ -34108,14 +34117,14 @@ const globPaths = async ({ globs, logger, pkgCwd, rootPath, }) => {
|
|
|
34108
34117
|
cwd = pkgDir;
|
|
34109
34118
|
}
|
|
34110
34119
|
const absRootPath = require$$0$1.posix.join(cwd.split(require$$0$1.sep).join(require$$0$1.posix.sep), rootPath.split(require$$0$1.sep).join(require$$0$1.posix.sep));
|
|
34111
|
-
const paths = await globby(globs, {
|
|
34120
|
+
const paths = await globby(globs.split(/\s+/), {
|
|
34112
34121
|
cwd: absRootPath,
|
|
34113
34122
|
expandDirectories: false,
|
|
34114
34123
|
onlyDirectories: true,
|
|
34115
34124
|
absolute: true,
|
|
34116
34125
|
});
|
|
34117
34126
|
if (!paths.length) {
|
|
34118
|
-
logger.error(`No paths found for globs '${globs
|
|
34127
|
+
logger.error(`No paths found for globs '${globs}' at '${absRootPath}'.`);
|
|
34119
34128
|
process.exit(0);
|
|
34120
34129
|
}
|
|
34121
34130
|
return { absRootPath, paths };
|
|
@@ -34136,7 +34145,7 @@ const execShellCommandBatch = async ({ command, globs, ignoreErrors, list, logge
|
|
|
34136
34145
|
: 'Executing shell command batch...';
|
|
34137
34146
|
logger.info('');
|
|
34138
34147
|
const headerRootPath = `ROOT: ${absRootPath}`;
|
|
34139
|
-
const headerGlobs = `GLOBS: ${globs
|
|
34148
|
+
const headerGlobs = `GLOBS: ${globs}`;
|
|
34140
34149
|
const headerCommand = `CMD: ${command}`;
|
|
34141
34150
|
logger.info('*'.repeat(Math.max(headerTitle.length, headerRootPath.length, headerGlobs.length, headerCommand.length)));
|
|
34142
34151
|
logger.info(headerTitle);
|
|
@@ -34183,18 +34192,21 @@ const cmdCommand$1 = new Command()
|
|
|
34183
34192
|
throw new Error(`unable to resolve parent command`);
|
|
34184
34193
|
if (!thisCommand.parent.parent)
|
|
34185
34194
|
throw new Error(`unable to resolve root command`);
|
|
34186
|
-
const { getDotenvOptions: { logger = console }, } = thisCommand.parent.parent;
|
|
34195
|
+
const { getDotenvOptions: { logger = console, shellScripts }, } = thisCommand.parent.parent;
|
|
34187
34196
|
const { ignoreErrors, globs, list, pkgCwd, rootPath } = thisCommand.parent.opts();
|
|
34188
34197
|
// Execute shell command.
|
|
34189
|
-
|
|
34190
|
-
command
|
|
34191
|
-
|
|
34192
|
-
|
|
34193
|
-
|
|
34194
|
-
|
|
34195
|
-
|
|
34196
|
-
|
|
34197
|
-
|
|
34198
|
+
{
|
|
34199
|
+
const command = thisCommand.args.join(' ');
|
|
34200
|
+
await execShellCommandBatch({
|
|
34201
|
+
command: shellScripts?.[command] ?? command,
|
|
34202
|
+
globs,
|
|
34203
|
+
ignoreErrors,
|
|
34204
|
+
list,
|
|
34205
|
+
logger,
|
|
34206
|
+
pkgCwd,
|
|
34207
|
+
rootPath,
|
|
34208
|
+
});
|
|
34209
|
+
}
|
|
34198
34210
|
});
|
|
34199
34211
|
|
|
34200
34212
|
const batchCommand = new Command()
|
|
@@ -34204,14 +34216,14 @@ const batchCommand = new Command()
|
|
|
34204
34216
|
.passThroughOptions()
|
|
34205
34217
|
.option('-p, --pkg-cwd', 'use nearest package directory as current working directory')
|
|
34206
34218
|
.option('-r, --root-path <string>', 'path to batch root directory from current working directory', './')
|
|
34207
|
-
.option('-g, --globs <
|
|
34219
|
+
.option('-g, --globs <string>', 'space-delimited globs from root path', '*')
|
|
34208
34220
|
.option('-c, --command <string>', 'shell command string, conflicts with cmd subcommand (dotenv-expanded)', dotenvExpandFromProcessEnv)
|
|
34209
34221
|
.option('-l, --list', 'list working directories without executing command')
|
|
34210
34222
|
.option('-e, --ignore-errors', 'ignore errors and continue with next path')
|
|
34211
34223
|
.hook('preSubcommand', async (thisCommand) => {
|
|
34212
34224
|
if (!thisCommand.parent)
|
|
34213
34225
|
throw new Error(`unable to resolve root command`);
|
|
34214
|
-
const { getDotenvOptions: { logger = console }, } = thisCommand.parent;
|
|
34226
|
+
const { getDotenvOptions: { logger = console, shellScripts }, } = thisCommand.parent;
|
|
34215
34227
|
const { command, ignoreErrors, globs, list, pkgCwd, rootPath } = thisCommand.opts();
|
|
34216
34228
|
if (command && thisCommand.args.length) {
|
|
34217
34229
|
logger.error(`--command option conflicts with cmd subcommand.`);
|
|
@@ -34220,7 +34232,7 @@ const batchCommand = new Command()
|
|
|
34220
34232
|
// Execute shell command.
|
|
34221
34233
|
if (command)
|
|
34222
34234
|
await execShellCommandBatch({
|
|
34223
|
-
command,
|
|
34235
|
+
command: shellScripts?.[command] ?? command,
|
|
34224
34236
|
globs,
|
|
34225
34237
|
ignoreErrors,
|
|
34226
34238
|
list,
|
|
@@ -34238,12 +34250,15 @@ const cmdCommand = new Command()
|
|
|
34238
34250
|
.enablePositionalOptions()
|
|
34239
34251
|
.passThroughOptions()
|
|
34240
34252
|
.action(async (options, thisCommand) => {
|
|
34253
|
+
if (thisCommand.args.length === 0)
|
|
34254
|
+
return;
|
|
34241
34255
|
if (!thisCommand.parent)
|
|
34242
34256
|
throw new Error('parent command not found');
|
|
34243
|
-
const { getDotenvOptions: { debug, logger = console }, } = thisCommand.parent;
|
|
34244
|
-
const
|
|
34257
|
+
const { getDotenvOptions: { debug, logger = console, shellScripts }, } = thisCommand.parent;
|
|
34258
|
+
const command = thisCommand.args.join(' ');
|
|
34259
|
+
const shellCommand = shellScripts?.[command] ?? command;
|
|
34245
34260
|
if (debug)
|
|
34246
|
-
logger.log('\n*** shell command ***\n', shellCommand);
|
|
34261
|
+
logger.log('\n*** shell command ***\n', `'${shellCommand}'`);
|
|
34247
34262
|
await execaCommand(shellCommand, {
|
|
34248
34263
|
shell: true,
|
|
34249
34264
|
stdio: 'inherit',
|
|
@@ -34254,10 +34269,15 @@ const cmdCommand = new Command()
|
|
|
34254
34269
|
* Generate a Commander CLI Command for get-dotenv.
|
|
34255
34270
|
*/
|
|
34256
34271
|
const generateGetDotenvCli = ({ logger = console, preHook, postHook, ...cliOptionsCustom } = {}) => {
|
|
34257
|
-
const { alias = 'getdotenv', debug, defaultEnv, description = 'Base CLI.', dotenvToken, dynamicPath, env, excludeDynamic, excludeEnv, excludeGlobal, excludePrivate, excludePublic, loadProcess, log, outputPath, paths, pathsDelimiter, pathsDelimiterPattern, privateToken, varsAssignor, varsAssignorPattern, varsDelimiter, varsDelimiterPattern, } = {
|
|
34272
|
+
const { alias = 'getdotenv', debug, defaultEnv, description = 'Base CLI.', dotenvToken, dynamicPath, env, excludeDynamic, excludeEnv, excludeGlobal, excludePrivate, excludePublic, loadProcess, log, outputPath, paths, pathsDelimiter, pathsDelimiterPattern, privateToken, shellScripts, varsAssignor, varsAssignorPattern, varsDelimiter, varsDelimiterPattern, } = {
|
|
34258
34273
|
...defaultGetDotenvCliOptionsGlobal,
|
|
34259
34274
|
...cliOptionsCustom,
|
|
34260
34275
|
...defaultGetDotenvCliOptionsLocal,
|
|
34276
|
+
shellScripts: {
|
|
34277
|
+
...(defaultGetDotenvCliOptionsGlobal.shellScripts ?? {}),
|
|
34278
|
+
...(cliOptionsCustom.shellScripts ?? {}),
|
|
34279
|
+
...(defaultGetDotenvCliOptionsLocal.shellScripts ?? {}),
|
|
34280
|
+
},
|
|
34261
34281
|
};
|
|
34262
34282
|
const excludeAll = !!excludeDynamic &&
|
|
34263
34283
|
((!!excludeEnv && !!excludeGlobal) ||
|
|
@@ -34305,6 +34325,9 @@ const generateGetDotenvCli = ({ logger = console, preHook, postHook, ...cliOptio
|
|
|
34305
34325
|
.option('--vars-delimiter-pattern <string>', 'vars delimiter regex pattern', varsDelimiterPattern)
|
|
34306
34326
|
.option('--vars-assignor <string>', 'vars assignment operator string', varsAssignor)
|
|
34307
34327
|
.option('--vars-assignor-pattern <string>', 'vars assignment operator regex pattern', varsAssignorPattern)
|
|
34328
|
+
.addOption(new Option('--shell-scripts <string>')
|
|
34329
|
+
.default(JSON.stringify(shellScripts))
|
|
34330
|
+
.hideHelp())
|
|
34308
34331
|
.addCommand(batchCommand)
|
|
34309
34332
|
.addCommand(cmdCommand, { isDefault: true })
|
|
34310
34333
|
.hook('preSubcommand', async (thisCommand) => {
|
|
@@ -34312,7 +34335,12 @@ const generateGetDotenvCli = ({ logger = console, preHook, postHook, ...cliOptio
|
|
|
34312
34335
|
if (rawOptions.debug)
|
|
34313
34336
|
logger.log('\n*** raw cli options ***\n', { rawOptions });
|
|
34314
34337
|
// Load options.
|
|
34315
|
-
const { command, debugOff, excludeAll, excludeAllOff, excludeDynamicOff, excludeEnvOff, excludeGlobalOff, excludePrivateOff, excludePublicOff, loadProcessOff, logOff, ...cliOptions } =
|
|
34338
|
+
const { command, debugOff, excludeAll, excludeAllOff, excludeDynamicOff, excludeEnvOff, excludeGlobalOff, excludePrivateOff, excludePublicOff, loadProcessOff, logOff, ...cliOptions } = {
|
|
34339
|
+
...rawOptions,
|
|
34340
|
+
shellScripts: rawOptions.shellScripts
|
|
34341
|
+
? JSON.parse(rawOptions.shellScripts)
|
|
34342
|
+
: undefined,
|
|
34343
|
+
};
|
|
34316
34344
|
// Resolve flags.
|
|
34317
34345
|
const resolveExclusion = (exclude, excludeOff, defaultValue) => exclude
|
|
34318
34346
|
? true
|
|
@@ -34351,10 +34379,7 @@ const generateGetDotenvCli = ({ logger = console, preHook, postHook, ...cliOptio
|
|
|
34351
34379
|
? JSON.parse(process.env.getDotenvOptions)
|
|
34352
34380
|
: {});
|
|
34353
34381
|
const cliGetDotenvOptions = getDotenvCliOptions2Options(cliOptions);
|
|
34354
|
-
const getDotenvOptions =
|
|
34355
|
-
...parentGetdotenvOptions,
|
|
34356
|
-
...cliGetDotenvOptions,
|
|
34357
|
-
};
|
|
34382
|
+
const getDotenvOptions = mergeGetDotenvOptions(cliGetDotenvOptions, parentGetdotenvOptions);
|
|
34358
34383
|
if (cliOptions.debug)
|
|
34359
34384
|
logger.log('\n*** getdotenv option resolution ***\n', {
|
|
34360
34385
|
parentGetdotenvOptions,
|
|
@@ -34362,9 +34387,9 @@ const generateGetDotenvCli = ({ logger = console, preHook, postHook, ...cliOptio
|
|
|
34362
34387
|
getDotenvOptions,
|
|
34363
34388
|
});
|
|
34364
34389
|
// Execute getdotenv.
|
|
34365
|
-
const
|
|
34366
|
-
_.set(thisCommand, 'getDotenvOptions',
|
|
34367
|
-
const dotenv = await getDotenv(
|
|
34390
|
+
const getDotenvOptionsProp = { ...getDotenvOptions, logger };
|
|
34391
|
+
_.set(thisCommand, 'getDotenvOptions', getDotenvOptionsProp);
|
|
34392
|
+
const dotenv = await getDotenv(getDotenvOptionsProp);
|
|
34368
34393
|
if (cliOptions.debug)
|
|
34369
34394
|
logger.log('\n*** resulting dotenv values ***\n', { dotenv });
|
|
34370
34395
|
// Execute post-hook.
|
|
@@ -34376,9 +34401,10 @@ const generateGetDotenvCli = ({ logger = console, preHook, postHook, ...cliOptio
|
|
|
34376
34401
|
process.exit(0);
|
|
34377
34402
|
}
|
|
34378
34403
|
if (command) {
|
|
34404
|
+
const shellCommand = getDotenvOptionsProp.shellScripts?.[command] ?? command;
|
|
34379
34405
|
if (cliOptions.debug)
|
|
34380
|
-
logger.log('\n*** shell command ***\n',
|
|
34381
|
-
await execaCommand(
|
|
34406
|
+
logger.log('\n*** shell command ***\n', shellCommand);
|
|
34407
|
+
await execaCommand(shellCommand, {
|
|
34382
34408
|
env: {
|
|
34383
34409
|
...process.env,
|
|
34384
34410
|
getDotenvOptions: JSON.stringify(getDotenvOptions),
|
package/dist/index.cjs
CHANGED
|
@@ -25766,6 +25766,7 @@ const defaultGetDotenvCliOptionsGlobal = {
|
|
|
25766
25766
|
paths: './',
|
|
25767
25767
|
pathsDelimiter: ' ',
|
|
25768
25768
|
privateToken: 'local',
|
|
25769
|
+
shellScripts: {},
|
|
25769
25770
|
vars: '',
|
|
25770
25771
|
varsAssignor: '=',
|
|
25771
25772
|
varsDelimiter: ' ',
|
|
@@ -25802,6 +25803,10 @@ const defaultGetDotenvCliOptionsLocal = (fs$a.existsSync(defaultGetDotenvCliOpti
|
|
|
25802
25803
|
const mergeGetDotenvOptions = (target = {}, source = {}) => ({
|
|
25803
25804
|
...source,
|
|
25804
25805
|
...target,
|
|
25806
|
+
shellScripts: {
|
|
25807
|
+
...(source.shellScripts ?? {}),
|
|
25808
|
+
...(target.shellScripts ?? {}),
|
|
25809
|
+
},
|
|
25805
25810
|
vars: _.pickBy({
|
|
25806
25811
|
...(source.vars ?? {}),
|
|
25807
25812
|
...(target.vars ?? {}),
|
|
@@ -25834,6 +25839,10 @@ const getDotenvCliOptions2Options = ({ paths, pathsDelimiter, pathsDelimiterPatt
|
|
|
25834
25839
|
const getDotenvDefaultOptions = getDotenvCliOptions2Options({
|
|
25835
25840
|
...defaultGetDotenvCliOptionsGlobal,
|
|
25836
25841
|
...defaultGetDotenvCliOptionsLocal,
|
|
25842
|
+
shellScripts: {
|
|
25843
|
+
...(defaultGetDotenvCliOptionsGlobal.shellScripts ?? {}),
|
|
25844
|
+
...(defaultGetDotenvCliOptionsLocal.shellScripts ?? {}),
|
|
25845
|
+
},
|
|
25837
25846
|
});
|
|
25838
25847
|
|
|
25839
25848
|
var main$1 = {exports: {}};
|
|
@@ -34110,14 +34119,14 @@ const globPaths = async ({ globs, logger, pkgCwd, rootPath, }) => {
|
|
|
34110
34119
|
cwd = pkgDir;
|
|
34111
34120
|
}
|
|
34112
34121
|
const absRootPath = require$$0$1.posix.join(cwd.split(require$$0$1.sep).join(require$$0$1.posix.sep), rootPath.split(require$$0$1.sep).join(require$$0$1.posix.sep));
|
|
34113
|
-
const paths = await globby(globs, {
|
|
34122
|
+
const paths = await globby(globs.split(/\s+/), {
|
|
34114
34123
|
cwd: absRootPath,
|
|
34115
34124
|
expandDirectories: false,
|
|
34116
34125
|
onlyDirectories: true,
|
|
34117
34126
|
absolute: true,
|
|
34118
34127
|
});
|
|
34119
34128
|
if (!paths.length) {
|
|
34120
|
-
logger.error(`No paths found for globs '${globs
|
|
34129
|
+
logger.error(`No paths found for globs '${globs}' at '${absRootPath}'.`);
|
|
34121
34130
|
process.exit(0);
|
|
34122
34131
|
}
|
|
34123
34132
|
return { absRootPath, paths };
|
|
@@ -34138,7 +34147,7 @@ const execShellCommandBatch = async ({ command, globs, ignoreErrors, list, logge
|
|
|
34138
34147
|
: 'Executing shell command batch...';
|
|
34139
34148
|
logger.info('');
|
|
34140
34149
|
const headerRootPath = `ROOT: ${absRootPath}`;
|
|
34141
|
-
const headerGlobs = `GLOBS: ${globs
|
|
34150
|
+
const headerGlobs = `GLOBS: ${globs}`;
|
|
34142
34151
|
const headerCommand = `CMD: ${command}`;
|
|
34143
34152
|
logger.info('*'.repeat(Math.max(headerTitle.length, headerRootPath.length, headerGlobs.length, headerCommand.length)));
|
|
34144
34153
|
logger.info(headerTitle);
|
|
@@ -34185,18 +34194,21 @@ const cmdCommand$1 = new Command()
|
|
|
34185
34194
|
throw new Error(`unable to resolve parent command`);
|
|
34186
34195
|
if (!thisCommand.parent.parent)
|
|
34187
34196
|
throw new Error(`unable to resolve root command`);
|
|
34188
|
-
const { getDotenvOptions: { logger = console }, } = thisCommand.parent.parent;
|
|
34197
|
+
const { getDotenvOptions: { logger = console, shellScripts }, } = thisCommand.parent.parent;
|
|
34189
34198
|
const { ignoreErrors, globs, list, pkgCwd, rootPath } = thisCommand.parent.opts();
|
|
34190
34199
|
// Execute shell command.
|
|
34191
|
-
|
|
34192
|
-
command
|
|
34193
|
-
|
|
34194
|
-
|
|
34195
|
-
|
|
34196
|
-
|
|
34197
|
-
|
|
34198
|
-
|
|
34199
|
-
|
|
34200
|
+
{
|
|
34201
|
+
const command = thisCommand.args.join(' ');
|
|
34202
|
+
await execShellCommandBatch({
|
|
34203
|
+
command: shellScripts?.[command] ?? command,
|
|
34204
|
+
globs,
|
|
34205
|
+
ignoreErrors,
|
|
34206
|
+
list,
|
|
34207
|
+
logger,
|
|
34208
|
+
pkgCwd,
|
|
34209
|
+
rootPath,
|
|
34210
|
+
});
|
|
34211
|
+
}
|
|
34200
34212
|
});
|
|
34201
34213
|
|
|
34202
34214
|
const batchCommand = new Command()
|
|
@@ -34206,14 +34218,14 @@ const batchCommand = new Command()
|
|
|
34206
34218
|
.passThroughOptions()
|
|
34207
34219
|
.option('-p, --pkg-cwd', 'use nearest package directory as current working directory')
|
|
34208
34220
|
.option('-r, --root-path <string>', 'path to batch root directory from current working directory', './')
|
|
34209
|
-
.option('-g, --globs <
|
|
34221
|
+
.option('-g, --globs <string>', 'space-delimited globs from root path', '*')
|
|
34210
34222
|
.option('-c, --command <string>', 'shell command string, conflicts with cmd subcommand (dotenv-expanded)', dotenvExpandFromProcessEnv)
|
|
34211
34223
|
.option('-l, --list', 'list working directories without executing command')
|
|
34212
34224
|
.option('-e, --ignore-errors', 'ignore errors and continue with next path')
|
|
34213
34225
|
.hook('preSubcommand', async (thisCommand) => {
|
|
34214
34226
|
if (!thisCommand.parent)
|
|
34215
34227
|
throw new Error(`unable to resolve root command`);
|
|
34216
|
-
const { getDotenvOptions: { logger = console }, } = thisCommand.parent;
|
|
34228
|
+
const { getDotenvOptions: { logger = console, shellScripts }, } = thisCommand.parent;
|
|
34217
34229
|
const { command, ignoreErrors, globs, list, pkgCwd, rootPath } = thisCommand.opts();
|
|
34218
34230
|
if (command && thisCommand.args.length) {
|
|
34219
34231
|
logger.error(`--command option conflicts with cmd subcommand.`);
|
|
@@ -34222,7 +34234,7 @@ const batchCommand = new Command()
|
|
|
34222
34234
|
// Execute shell command.
|
|
34223
34235
|
if (command)
|
|
34224
34236
|
await execShellCommandBatch({
|
|
34225
|
-
command,
|
|
34237
|
+
command: shellScripts?.[command] ?? command,
|
|
34226
34238
|
globs,
|
|
34227
34239
|
ignoreErrors,
|
|
34228
34240
|
list,
|
|
@@ -34240,12 +34252,15 @@ const cmdCommand = new Command()
|
|
|
34240
34252
|
.enablePositionalOptions()
|
|
34241
34253
|
.passThroughOptions()
|
|
34242
34254
|
.action(async (options, thisCommand) => {
|
|
34255
|
+
if (thisCommand.args.length === 0)
|
|
34256
|
+
return;
|
|
34243
34257
|
if (!thisCommand.parent)
|
|
34244
34258
|
throw new Error('parent command not found');
|
|
34245
|
-
const { getDotenvOptions: { debug, logger = console }, } = thisCommand.parent;
|
|
34246
|
-
const
|
|
34259
|
+
const { getDotenvOptions: { debug, logger = console, shellScripts }, } = thisCommand.parent;
|
|
34260
|
+
const command = thisCommand.args.join(' ');
|
|
34261
|
+
const shellCommand = shellScripts?.[command] ?? command;
|
|
34247
34262
|
if (debug)
|
|
34248
|
-
logger.log('\n*** shell command ***\n', shellCommand);
|
|
34263
|
+
logger.log('\n*** shell command ***\n', `'${shellCommand}'`);
|
|
34249
34264
|
await execaCommand(shellCommand, {
|
|
34250
34265
|
shell: true,
|
|
34251
34266
|
stdio: 'inherit',
|
|
@@ -34256,10 +34271,15 @@ const cmdCommand = new Command()
|
|
|
34256
34271
|
* Generate a Commander CLI Command for get-dotenv.
|
|
34257
34272
|
*/
|
|
34258
34273
|
const generateGetDotenvCli = ({ logger = console, preHook, postHook, ...cliOptionsCustom } = {}) => {
|
|
34259
|
-
const { alias = 'getdotenv', debug, defaultEnv, description = 'Base CLI.', dotenvToken, dynamicPath, env, excludeDynamic, excludeEnv, excludeGlobal, excludePrivate, excludePublic, loadProcess, log, outputPath, paths, pathsDelimiter, pathsDelimiterPattern, privateToken, varsAssignor, varsAssignorPattern, varsDelimiter, varsDelimiterPattern, } = {
|
|
34274
|
+
const { alias = 'getdotenv', debug, defaultEnv, description = 'Base CLI.', dotenvToken, dynamicPath, env, excludeDynamic, excludeEnv, excludeGlobal, excludePrivate, excludePublic, loadProcess, log, outputPath, paths, pathsDelimiter, pathsDelimiterPattern, privateToken, shellScripts, varsAssignor, varsAssignorPattern, varsDelimiter, varsDelimiterPattern, } = {
|
|
34260
34275
|
...defaultGetDotenvCliOptionsGlobal,
|
|
34261
34276
|
...cliOptionsCustom,
|
|
34262
34277
|
...defaultGetDotenvCliOptionsLocal,
|
|
34278
|
+
shellScripts: {
|
|
34279
|
+
...(defaultGetDotenvCliOptionsGlobal.shellScripts ?? {}),
|
|
34280
|
+
...(cliOptionsCustom.shellScripts ?? {}),
|
|
34281
|
+
...(defaultGetDotenvCliOptionsLocal.shellScripts ?? {}),
|
|
34282
|
+
},
|
|
34263
34283
|
};
|
|
34264
34284
|
const excludeAll = !!excludeDynamic &&
|
|
34265
34285
|
((!!excludeEnv && !!excludeGlobal) ||
|
|
@@ -34307,6 +34327,9 @@ const generateGetDotenvCli = ({ logger = console, preHook, postHook, ...cliOptio
|
|
|
34307
34327
|
.option('--vars-delimiter-pattern <string>', 'vars delimiter regex pattern', varsDelimiterPattern)
|
|
34308
34328
|
.option('--vars-assignor <string>', 'vars assignment operator string', varsAssignor)
|
|
34309
34329
|
.option('--vars-assignor-pattern <string>', 'vars assignment operator regex pattern', varsAssignorPattern)
|
|
34330
|
+
.addOption(new Option('--shell-scripts <string>')
|
|
34331
|
+
.default(JSON.stringify(shellScripts))
|
|
34332
|
+
.hideHelp())
|
|
34310
34333
|
.addCommand(batchCommand)
|
|
34311
34334
|
.addCommand(cmdCommand, { isDefault: true })
|
|
34312
34335
|
.hook('preSubcommand', async (thisCommand) => {
|
|
@@ -34314,7 +34337,12 @@ const generateGetDotenvCli = ({ logger = console, preHook, postHook, ...cliOptio
|
|
|
34314
34337
|
if (rawOptions.debug)
|
|
34315
34338
|
logger.log('\n*** raw cli options ***\n', { rawOptions });
|
|
34316
34339
|
// Load options.
|
|
34317
|
-
const { command, debugOff, excludeAll, excludeAllOff, excludeDynamicOff, excludeEnvOff, excludeGlobalOff, excludePrivateOff, excludePublicOff, loadProcessOff, logOff, ...cliOptions } =
|
|
34340
|
+
const { command, debugOff, excludeAll, excludeAllOff, excludeDynamicOff, excludeEnvOff, excludeGlobalOff, excludePrivateOff, excludePublicOff, loadProcessOff, logOff, ...cliOptions } = {
|
|
34341
|
+
...rawOptions,
|
|
34342
|
+
shellScripts: rawOptions.shellScripts
|
|
34343
|
+
? JSON.parse(rawOptions.shellScripts)
|
|
34344
|
+
: undefined,
|
|
34345
|
+
};
|
|
34318
34346
|
// Resolve flags.
|
|
34319
34347
|
const resolveExclusion = (exclude, excludeOff, defaultValue) => exclude
|
|
34320
34348
|
? true
|
|
@@ -34353,10 +34381,7 @@ const generateGetDotenvCli = ({ logger = console, preHook, postHook, ...cliOptio
|
|
|
34353
34381
|
? JSON.parse(process.env.getDotenvOptions)
|
|
34354
34382
|
: {});
|
|
34355
34383
|
const cliGetDotenvOptions = getDotenvCliOptions2Options(cliOptions);
|
|
34356
|
-
const getDotenvOptions =
|
|
34357
|
-
...parentGetdotenvOptions,
|
|
34358
|
-
...cliGetDotenvOptions,
|
|
34359
|
-
};
|
|
34384
|
+
const getDotenvOptions = mergeGetDotenvOptions(cliGetDotenvOptions, parentGetdotenvOptions);
|
|
34360
34385
|
if (cliOptions.debug)
|
|
34361
34386
|
logger.log('\n*** getdotenv option resolution ***\n', {
|
|
34362
34387
|
parentGetdotenvOptions,
|
|
@@ -34364,9 +34389,9 @@ const generateGetDotenvCli = ({ logger = console, preHook, postHook, ...cliOptio
|
|
|
34364
34389
|
getDotenvOptions,
|
|
34365
34390
|
});
|
|
34366
34391
|
// Execute getdotenv.
|
|
34367
|
-
const
|
|
34368
|
-
_.set(thisCommand, 'getDotenvOptions',
|
|
34369
|
-
const dotenv = await getDotenv(
|
|
34392
|
+
const getDotenvOptionsProp = { ...getDotenvOptions, logger };
|
|
34393
|
+
_.set(thisCommand, 'getDotenvOptions', getDotenvOptionsProp);
|
|
34394
|
+
const dotenv = await getDotenv(getDotenvOptionsProp);
|
|
34370
34395
|
if (cliOptions.debug)
|
|
34371
34396
|
logger.log('\n*** resulting dotenv values ***\n', { dotenv });
|
|
34372
34397
|
// Execute post-hook.
|
|
@@ -34378,9 +34403,10 @@ const generateGetDotenvCli = ({ logger = console, preHook, postHook, ...cliOptio
|
|
|
34378
34403
|
process.exit(0);
|
|
34379
34404
|
}
|
|
34380
34405
|
if (command) {
|
|
34406
|
+
const shellCommand = getDotenvOptionsProp.shellScripts?.[command] ?? command;
|
|
34381
34407
|
if (cliOptions.debug)
|
|
34382
|
-
logger.log('\n*** shell command ***\n',
|
|
34383
|
-
await execaCommand(
|
|
34408
|
+
logger.log('\n*** shell command ***\n', shellCommand);
|
|
34409
|
+
await execaCommand(shellCommand, {
|
|
34384
34410
|
env: {
|
|
34385
34411
|
...process.env,
|
|
34386
34412
|
getDotenvOptions: JSON.stringify(getDotenvOptions),
|
package/dist/index.d.cts
CHANGED
|
@@ -5,7 +5,7 @@ import { Command } from '@commander-js/extra-typings';
|
|
|
5
5
|
*/
|
|
6
6
|
interface GetDotenvCliOptions extends Omit<GetDotenvOptions, 'paths' | 'vars'> {
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* CLI alias. Should align with the `bin` property in `package.json`.
|
|
9
9
|
*/
|
|
10
10
|
alias?: string;
|
|
11
11
|
/**
|
|
@@ -129,6 +129,10 @@ interface GetDotenvOptions {
|
|
|
129
129
|
* filename token indicating private variables
|
|
130
130
|
*/
|
|
131
131
|
privateToken?: string;
|
|
132
|
+
/**
|
|
133
|
+
* Shell scripts that can be executed from the CLI, either individually or via the batch subcommand.
|
|
134
|
+
*/
|
|
135
|
+
shellScripts?: Record<string, string>;
|
|
132
136
|
/**
|
|
133
137
|
* explicit variables to include
|
|
134
138
|
*/
|
package/dist/index.d.mts
CHANGED
|
@@ -5,7 +5,7 @@ import { Command } from '@commander-js/extra-typings';
|
|
|
5
5
|
*/
|
|
6
6
|
interface GetDotenvCliOptions extends Omit<GetDotenvOptions, 'paths' | 'vars'> {
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* CLI alias. Should align with the `bin` property in `package.json`.
|
|
9
9
|
*/
|
|
10
10
|
alias?: string;
|
|
11
11
|
/**
|
|
@@ -129,6 +129,10 @@ interface GetDotenvOptions {
|
|
|
129
129
|
* filename token indicating private variables
|
|
130
130
|
*/
|
|
131
131
|
privateToken?: string;
|
|
132
|
+
/**
|
|
133
|
+
* Shell scripts that can be executed from the CLI, either individually or via the batch subcommand.
|
|
134
|
+
*/
|
|
135
|
+
shellScripts?: Record<string, string>;
|
|
132
136
|
/**
|
|
133
137
|
* explicit variables to include
|
|
134
138
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { Command } from '@commander-js/extra-typings';
|
|
|
5
5
|
*/
|
|
6
6
|
interface GetDotenvCliOptions extends Omit<GetDotenvOptions, 'paths' | 'vars'> {
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* CLI alias. Should align with the `bin` property in `package.json`.
|
|
9
9
|
*/
|
|
10
10
|
alias?: string;
|
|
11
11
|
/**
|
|
@@ -129,6 +129,10 @@ interface GetDotenvOptions {
|
|
|
129
129
|
* filename token indicating private variables
|
|
130
130
|
*/
|
|
131
131
|
privateToken?: string;
|
|
132
|
+
/**
|
|
133
|
+
* Shell scripts that can be executed from the CLI, either individually or via the batch subcommand.
|
|
134
|
+
*/
|
|
135
|
+
shellScripts?: Record<string, string>;
|
|
132
136
|
/**
|
|
133
137
|
* explicit variables to include
|
|
134
138
|
*/
|
package/dist/index.mjs
CHANGED
|
@@ -25763,6 +25763,7 @@ const defaultGetDotenvCliOptionsGlobal = {
|
|
|
25763
25763
|
paths: './',
|
|
25764
25764
|
pathsDelimiter: ' ',
|
|
25765
25765
|
privateToken: 'local',
|
|
25766
|
+
shellScripts: {},
|
|
25766
25767
|
vars: '',
|
|
25767
25768
|
varsAssignor: '=',
|
|
25768
25769
|
varsDelimiter: ' ',
|
|
@@ -25799,6 +25800,10 @@ const defaultGetDotenvCliOptionsLocal = (fs$a.existsSync(defaultGetDotenvCliOpti
|
|
|
25799
25800
|
const mergeGetDotenvOptions = (target = {}, source = {}) => ({
|
|
25800
25801
|
...source,
|
|
25801
25802
|
...target,
|
|
25803
|
+
shellScripts: {
|
|
25804
|
+
...(source.shellScripts ?? {}),
|
|
25805
|
+
...(target.shellScripts ?? {}),
|
|
25806
|
+
},
|
|
25802
25807
|
vars: _.pickBy({
|
|
25803
25808
|
...(source.vars ?? {}),
|
|
25804
25809
|
...(target.vars ?? {}),
|
|
@@ -25831,6 +25836,10 @@ const getDotenvCliOptions2Options = ({ paths, pathsDelimiter, pathsDelimiterPatt
|
|
|
25831
25836
|
const getDotenvDefaultOptions = getDotenvCliOptions2Options({
|
|
25832
25837
|
...defaultGetDotenvCliOptionsGlobal,
|
|
25833
25838
|
...defaultGetDotenvCliOptionsLocal,
|
|
25839
|
+
shellScripts: {
|
|
25840
|
+
...(defaultGetDotenvCliOptionsGlobal.shellScripts ?? {}),
|
|
25841
|
+
...(defaultGetDotenvCliOptionsLocal.shellScripts ?? {}),
|
|
25842
|
+
},
|
|
25834
25843
|
});
|
|
25835
25844
|
|
|
25836
25845
|
var main$1 = {exports: {}};
|
|
@@ -34107,14 +34116,14 @@ const globPaths = async ({ globs, logger, pkgCwd, rootPath, }) => {
|
|
|
34107
34116
|
cwd = pkgDir;
|
|
34108
34117
|
}
|
|
34109
34118
|
const absRootPath = require$$0$1.posix.join(cwd.split(require$$0$1.sep).join(require$$0$1.posix.sep), rootPath.split(require$$0$1.sep).join(require$$0$1.posix.sep));
|
|
34110
|
-
const paths = await globby(globs, {
|
|
34119
|
+
const paths = await globby(globs.split(/\s+/), {
|
|
34111
34120
|
cwd: absRootPath,
|
|
34112
34121
|
expandDirectories: false,
|
|
34113
34122
|
onlyDirectories: true,
|
|
34114
34123
|
absolute: true,
|
|
34115
34124
|
});
|
|
34116
34125
|
if (!paths.length) {
|
|
34117
|
-
logger.error(`No paths found for globs '${globs
|
|
34126
|
+
logger.error(`No paths found for globs '${globs}' at '${absRootPath}'.`);
|
|
34118
34127
|
process.exit(0);
|
|
34119
34128
|
}
|
|
34120
34129
|
return { absRootPath, paths };
|
|
@@ -34135,7 +34144,7 @@ const execShellCommandBatch = async ({ command, globs, ignoreErrors, list, logge
|
|
|
34135
34144
|
: 'Executing shell command batch...';
|
|
34136
34145
|
logger.info('');
|
|
34137
34146
|
const headerRootPath = `ROOT: ${absRootPath}`;
|
|
34138
|
-
const headerGlobs = `GLOBS: ${globs
|
|
34147
|
+
const headerGlobs = `GLOBS: ${globs}`;
|
|
34139
34148
|
const headerCommand = `CMD: ${command}`;
|
|
34140
34149
|
logger.info('*'.repeat(Math.max(headerTitle.length, headerRootPath.length, headerGlobs.length, headerCommand.length)));
|
|
34141
34150
|
logger.info(headerTitle);
|
|
@@ -34182,18 +34191,21 @@ const cmdCommand$1 = new Command()
|
|
|
34182
34191
|
throw new Error(`unable to resolve parent command`);
|
|
34183
34192
|
if (!thisCommand.parent.parent)
|
|
34184
34193
|
throw new Error(`unable to resolve root command`);
|
|
34185
|
-
const { getDotenvOptions: { logger = console }, } = thisCommand.parent.parent;
|
|
34194
|
+
const { getDotenvOptions: { logger = console, shellScripts }, } = thisCommand.parent.parent;
|
|
34186
34195
|
const { ignoreErrors, globs, list, pkgCwd, rootPath } = thisCommand.parent.opts();
|
|
34187
34196
|
// Execute shell command.
|
|
34188
|
-
|
|
34189
|
-
command
|
|
34190
|
-
|
|
34191
|
-
|
|
34192
|
-
|
|
34193
|
-
|
|
34194
|
-
|
|
34195
|
-
|
|
34196
|
-
|
|
34197
|
+
{
|
|
34198
|
+
const command = thisCommand.args.join(' ');
|
|
34199
|
+
await execShellCommandBatch({
|
|
34200
|
+
command: shellScripts?.[command] ?? command,
|
|
34201
|
+
globs,
|
|
34202
|
+
ignoreErrors,
|
|
34203
|
+
list,
|
|
34204
|
+
logger,
|
|
34205
|
+
pkgCwd,
|
|
34206
|
+
rootPath,
|
|
34207
|
+
});
|
|
34208
|
+
}
|
|
34197
34209
|
});
|
|
34198
34210
|
|
|
34199
34211
|
const batchCommand = new Command()
|
|
@@ -34203,14 +34215,14 @@ const batchCommand = new Command()
|
|
|
34203
34215
|
.passThroughOptions()
|
|
34204
34216
|
.option('-p, --pkg-cwd', 'use nearest package directory as current working directory')
|
|
34205
34217
|
.option('-r, --root-path <string>', 'path to batch root directory from current working directory', './')
|
|
34206
|
-
.option('-g, --globs <
|
|
34218
|
+
.option('-g, --globs <string>', 'space-delimited globs from root path', '*')
|
|
34207
34219
|
.option('-c, --command <string>', 'shell command string, conflicts with cmd subcommand (dotenv-expanded)', dotenvExpandFromProcessEnv)
|
|
34208
34220
|
.option('-l, --list', 'list working directories without executing command')
|
|
34209
34221
|
.option('-e, --ignore-errors', 'ignore errors and continue with next path')
|
|
34210
34222
|
.hook('preSubcommand', async (thisCommand) => {
|
|
34211
34223
|
if (!thisCommand.parent)
|
|
34212
34224
|
throw new Error(`unable to resolve root command`);
|
|
34213
|
-
const { getDotenvOptions: { logger = console }, } = thisCommand.parent;
|
|
34225
|
+
const { getDotenvOptions: { logger = console, shellScripts }, } = thisCommand.parent;
|
|
34214
34226
|
const { command, ignoreErrors, globs, list, pkgCwd, rootPath } = thisCommand.opts();
|
|
34215
34227
|
if (command && thisCommand.args.length) {
|
|
34216
34228
|
logger.error(`--command option conflicts with cmd subcommand.`);
|
|
@@ -34219,7 +34231,7 @@ const batchCommand = new Command()
|
|
|
34219
34231
|
// Execute shell command.
|
|
34220
34232
|
if (command)
|
|
34221
34233
|
await execShellCommandBatch({
|
|
34222
|
-
command,
|
|
34234
|
+
command: shellScripts?.[command] ?? command,
|
|
34223
34235
|
globs,
|
|
34224
34236
|
ignoreErrors,
|
|
34225
34237
|
list,
|
|
@@ -34237,12 +34249,15 @@ const cmdCommand = new Command()
|
|
|
34237
34249
|
.enablePositionalOptions()
|
|
34238
34250
|
.passThroughOptions()
|
|
34239
34251
|
.action(async (options, thisCommand) => {
|
|
34252
|
+
if (thisCommand.args.length === 0)
|
|
34253
|
+
return;
|
|
34240
34254
|
if (!thisCommand.parent)
|
|
34241
34255
|
throw new Error('parent command not found');
|
|
34242
|
-
const { getDotenvOptions: { debug, logger = console }, } = thisCommand.parent;
|
|
34243
|
-
const
|
|
34256
|
+
const { getDotenvOptions: { debug, logger = console, shellScripts }, } = thisCommand.parent;
|
|
34257
|
+
const command = thisCommand.args.join(' ');
|
|
34258
|
+
const shellCommand = shellScripts?.[command] ?? command;
|
|
34244
34259
|
if (debug)
|
|
34245
|
-
logger.log('\n*** shell command ***\n', shellCommand);
|
|
34260
|
+
logger.log('\n*** shell command ***\n', `'${shellCommand}'`);
|
|
34246
34261
|
await execaCommand(shellCommand, {
|
|
34247
34262
|
shell: true,
|
|
34248
34263
|
stdio: 'inherit',
|
|
@@ -34253,10 +34268,15 @@ const cmdCommand = new Command()
|
|
|
34253
34268
|
* Generate a Commander CLI Command for get-dotenv.
|
|
34254
34269
|
*/
|
|
34255
34270
|
const generateGetDotenvCli = ({ logger = console, preHook, postHook, ...cliOptionsCustom } = {}) => {
|
|
34256
|
-
const { alias = 'getdotenv', debug, defaultEnv, description = 'Base CLI.', dotenvToken, dynamicPath, env, excludeDynamic, excludeEnv, excludeGlobal, excludePrivate, excludePublic, loadProcess, log, outputPath, paths, pathsDelimiter, pathsDelimiterPattern, privateToken, varsAssignor, varsAssignorPattern, varsDelimiter, varsDelimiterPattern, } = {
|
|
34271
|
+
const { alias = 'getdotenv', debug, defaultEnv, description = 'Base CLI.', dotenvToken, dynamicPath, env, excludeDynamic, excludeEnv, excludeGlobal, excludePrivate, excludePublic, loadProcess, log, outputPath, paths, pathsDelimiter, pathsDelimiterPattern, privateToken, shellScripts, varsAssignor, varsAssignorPattern, varsDelimiter, varsDelimiterPattern, } = {
|
|
34257
34272
|
...defaultGetDotenvCliOptionsGlobal,
|
|
34258
34273
|
...cliOptionsCustom,
|
|
34259
34274
|
...defaultGetDotenvCliOptionsLocal,
|
|
34275
|
+
shellScripts: {
|
|
34276
|
+
...(defaultGetDotenvCliOptionsGlobal.shellScripts ?? {}),
|
|
34277
|
+
...(cliOptionsCustom.shellScripts ?? {}),
|
|
34278
|
+
...(defaultGetDotenvCliOptionsLocal.shellScripts ?? {}),
|
|
34279
|
+
},
|
|
34260
34280
|
};
|
|
34261
34281
|
const excludeAll = !!excludeDynamic &&
|
|
34262
34282
|
((!!excludeEnv && !!excludeGlobal) ||
|
|
@@ -34304,6 +34324,9 @@ const generateGetDotenvCli = ({ logger = console, preHook, postHook, ...cliOptio
|
|
|
34304
34324
|
.option('--vars-delimiter-pattern <string>', 'vars delimiter regex pattern', varsDelimiterPattern)
|
|
34305
34325
|
.option('--vars-assignor <string>', 'vars assignment operator string', varsAssignor)
|
|
34306
34326
|
.option('--vars-assignor-pattern <string>', 'vars assignment operator regex pattern', varsAssignorPattern)
|
|
34327
|
+
.addOption(new Option('--shell-scripts <string>')
|
|
34328
|
+
.default(JSON.stringify(shellScripts))
|
|
34329
|
+
.hideHelp())
|
|
34307
34330
|
.addCommand(batchCommand)
|
|
34308
34331
|
.addCommand(cmdCommand, { isDefault: true })
|
|
34309
34332
|
.hook('preSubcommand', async (thisCommand) => {
|
|
@@ -34311,7 +34334,12 @@ const generateGetDotenvCli = ({ logger = console, preHook, postHook, ...cliOptio
|
|
|
34311
34334
|
if (rawOptions.debug)
|
|
34312
34335
|
logger.log('\n*** raw cli options ***\n', { rawOptions });
|
|
34313
34336
|
// Load options.
|
|
34314
|
-
const { command, debugOff, excludeAll, excludeAllOff, excludeDynamicOff, excludeEnvOff, excludeGlobalOff, excludePrivateOff, excludePublicOff, loadProcessOff, logOff, ...cliOptions } =
|
|
34337
|
+
const { command, debugOff, excludeAll, excludeAllOff, excludeDynamicOff, excludeEnvOff, excludeGlobalOff, excludePrivateOff, excludePublicOff, loadProcessOff, logOff, ...cliOptions } = {
|
|
34338
|
+
...rawOptions,
|
|
34339
|
+
shellScripts: rawOptions.shellScripts
|
|
34340
|
+
? JSON.parse(rawOptions.shellScripts)
|
|
34341
|
+
: undefined,
|
|
34342
|
+
};
|
|
34315
34343
|
// Resolve flags.
|
|
34316
34344
|
const resolveExclusion = (exclude, excludeOff, defaultValue) => exclude
|
|
34317
34345
|
? true
|
|
@@ -34350,10 +34378,7 @@ const generateGetDotenvCli = ({ logger = console, preHook, postHook, ...cliOptio
|
|
|
34350
34378
|
? JSON.parse(process.env.getDotenvOptions)
|
|
34351
34379
|
: {});
|
|
34352
34380
|
const cliGetDotenvOptions = getDotenvCliOptions2Options(cliOptions);
|
|
34353
|
-
const getDotenvOptions =
|
|
34354
|
-
...parentGetdotenvOptions,
|
|
34355
|
-
...cliGetDotenvOptions,
|
|
34356
|
-
};
|
|
34381
|
+
const getDotenvOptions = mergeGetDotenvOptions(cliGetDotenvOptions, parentGetdotenvOptions);
|
|
34357
34382
|
if (cliOptions.debug)
|
|
34358
34383
|
logger.log('\n*** getdotenv option resolution ***\n', {
|
|
34359
34384
|
parentGetdotenvOptions,
|
|
@@ -34361,9 +34386,9 @@ const generateGetDotenvCli = ({ logger = console, preHook, postHook, ...cliOptio
|
|
|
34361
34386
|
getDotenvOptions,
|
|
34362
34387
|
});
|
|
34363
34388
|
// Execute getdotenv.
|
|
34364
|
-
const
|
|
34365
|
-
_.set(thisCommand, 'getDotenvOptions',
|
|
34366
|
-
const dotenv = await getDotenv(
|
|
34389
|
+
const getDotenvOptionsProp = { ...getDotenvOptions, logger };
|
|
34390
|
+
_.set(thisCommand, 'getDotenvOptions', getDotenvOptionsProp);
|
|
34391
|
+
const dotenv = await getDotenv(getDotenvOptionsProp);
|
|
34367
34392
|
if (cliOptions.debug)
|
|
34368
34393
|
logger.log('\n*** resulting dotenv values ***\n', { dotenv });
|
|
34369
34394
|
// Execute post-hook.
|
|
@@ -34375,9 +34400,10 @@ const generateGetDotenvCli = ({ logger = console, preHook, postHook, ...cliOptio
|
|
|
34375
34400
|
process.exit(0);
|
|
34376
34401
|
}
|
|
34377
34402
|
if (command) {
|
|
34403
|
+
const shellCommand = getDotenvOptionsProp.shellScripts?.[command] ?? command;
|
|
34378
34404
|
if (cliOptions.debug)
|
|
34379
|
-
logger.log('\n*** shell command ***\n',
|
|
34380
|
-
await execaCommand(
|
|
34405
|
+
logger.log('\n*** shell command ***\n', shellCommand);
|
|
34406
|
+
await execaCommand(shellCommand, {
|
|
34381
34407
|
env: {
|
|
34382
34408
|
...process.env,
|
|
34383
34409
|
getDotenvOptions: JSON.stringify(getDotenvOptions),
|
package/package.json
CHANGED