@karmaniverous/get-dotenv 4.2.1 → 4.2.2
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/dist/getdotenv.cli.mjs +113 -185
- package/dist/index.cjs +110 -183
- package/dist/index.d.cts +22 -22
- package/dist/index.d.mts +22 -22
- package/dist/index.d.ts +22 -22
- package/dist/index.mjs +112 -184
- package/package.json +1 -1
package/dist/getdotenv.cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import require$$0 from 'events';
|
|
3
3
|
import require$$1 from 'child_process';
|
|
4
|
-
import require$$0$1
|
|
4
|
+
import require$$0$1 from 'path';
|
|
5
5
|
import require$$0$2 from 'fs';
|
|
6
6
|
import require$$4$1 from 'process';
|
|
7
7
|
import { Buffer as Buffer$1 } from 'node:buffer';
|
|
@@ -18,7 +18,7 @@ import require$$0$4 from 'constants';
|
|
|
18
18
|
import require$$0$5 from 'util';
|
|
19
19
|
import require$$5 from 'assert';
|
|
20
20
|
import { webcrypto } from 'node:crypto';
|
|
21
|
-
import url, { fileURLToPath as fileURLToPath$1 } from 'url';
|
|
21
|
+
import url, { resolve, fileURLToPath as fileURLToPath$1 } from 'url';
|
|
22
22
|
import fsPromises from 'node:fs/promises';
|
|
23
23
|
import require$$2 from 'os';
|
|
24
24
|
import require$$3 from 'crypto';
|
|
@@ -25701,115 +25701,27 @@ async function findUp(name, {
|
|
|
25701
25701
|
}
|
|
25702
25702
|
}
|
|
25703
25703
|
|
|
25704
|
-
function findUpSync(name, {
|
|
25705
|
-
cwd = process$3.cwd(),
|
|
25706
|
-
type = 'file',
|
|
25707
|
-
stopAt,
|
|
25708
|
-
} = {}) {
|
|
25709
|
-
let directory = path$s.resolve(toPath$1(cwd) ?? '');
|
|
25710
|
-
const {root} = path$s.parse(directory);
|
|
25711
|
-
stopAt = path$s.resolve(directory, toPath$1(stopAt) ?? root);
|
|
25712
|
-
|
|
25713
|
-
while (directory && directory !== stopAt && directory !== root) {
|
|
25714
|
-
const filePath = path$s.isAbsolute(name) ? name : path$s.join(directory, name);
|
|
25715
|
-
|
|
25716
|
-
try {
|
|
25717
|
-
const stats = fs$v.statSync(filePath, {throwIfNoEntry: false});
|
|
25718
|
-
if ((type === 'file' && stats?.isFile()) || (type === 'directory' && stats?.isDirectory())) {
|
|
25719
|
-
return filePath;
|
|
25720
|
-
}
|
|
25721
|
-
} catch {}
|
|
25722
|
-
|
|
25723
|
-
directory = path$s.dirname(directory);
|
|
25724
|
-
}
|
|
25725
|
-
}
|
|
25726
|
-
|
|
25727
25704
|
async function packageDirectory({cwd} = {}) {
|
|
25728
25705
|
const filePath = await findUp('package.json', {cwd});
|
|
25729
25706
|
return filePath && path$s.dirname(filePath);
|
|
25730
25707
|
}
|
|
25731
25708
|
|
|
25732
|
-
|
|
25733
|
-
const filePath = findUpSync('package.json', {cwd});
|
|
25734
|
-
return filePath && path$s.dirname(filePath);
|
|
25735
|
-
}
|
|
25736
|
-
|
|
25737
|
-
const __dirname = dirname(fileURLToPath$1(import.meta.url));
|
|
25738
|
-
/**
|
|
25739
|
-
* Absolute path to the global default CLI options file `getdotenv.config.json`.
|
|
25740
|
-
*
|
|
25741
|
-
* If `get-dotenv` is imported directly, this is the `getdotenv.config.json`
|
|
25742
|
-
* file at the root of the `get-dotenv` package.
|
|
25743
|
-
*
|
|
25744
|
-
* If `get-dotenv` has been used to generate a CLI which is in turn being
|
|
25745
|
-
* imported, this is the `getdotenv.config.json` file at the root of the
|
|
25746
|
-
* imported package.
|
|
25747
|
-
*/
|
|
25748
|
-
const defaultGetDotenvCliOptionsGlobalPath = resolve(__dirname, '../getdotenv.config.json');
|
|
25749
|
-
/**
|
|
25750
|
-
* Global default CLI options.
|
|
25751
|
-
*
|
|
25752
|
-
* If `get-dotenv` is imported directly, these are derived from the
|
|
25753
|
-
* `getdotenv.config.json` file at the root of the `get-dotenv` package.
|
|
25754
|
-
*
|
|
25755
|
-
* If `get-dotenv` has been used to generate a CLI which is in turn being
|
|
25756
|
-
* imported, they are derived from the `getdotenv.config.json` file at the root
|
|
25757
|
-
* of the imported package.
|
|
25758
|
-
*
|
|
25759
|
-
* @defaultValue `{}`
|
|
25760
|
-
*/
|
|
25761
|
-
const defaultGetDotenvCliOptionsGlobal = {
|
|
25709
|
+
const baseGetDotenvCliOptions = {
|
|
25762
25710
|
dotenvToken: '.env',
|
|
25763
25711
|
loadProcess: true,
|
|
25712
|
+
logger: console,
|
|
25764
25713
|
paths: './',
|
|
25765
25714
|
pathsDelimiter: ' ',
|
|
25766
25715
|
privateToken: 'local',
|
|
25767
|
-
shellScripts: {
|
|
25716
|
+
shellScripts: {
|
|
25717
|
+
'git-status': 'git branch --show-current && git status -s -u',
|
|
25718
|
+
},
|
|
25768
25719
|
vars: '',
|
|
25769
25720
|
varsAssignor: '=',
|
|
25770
25721
|
varsDelimiter: ' ',
|
|
25771
|
-
...(fs$a.existsSync(defaultGetDotenvCliOptionsGlobalPath)
|
|
25772
|
-
? JSON.parse(fs$a.readFileSync(defaultGetDotenvCliOptionsGlobalPath).toString())
|
|
25773
|
-
: {}),
|
|
25774
25722
|
};
|
|
25775
|
-
/**
|
|
25776
|
-
* Path to the nearest package directory.
|
|
25777
|
-
*/
|
|
25778
|
-
const pkgDir = packageDirectorySync();
|
|
25779
|
-
if (!pkgDir)
|
|
25780
|
-
throw new Error('Package directory not found.');
|
|
25781
|
-
/**
|
|
25782
|
-
* Absolute path to the local default CLI options file `getdotenv.config.json`.
|
|
25783
|
-
*/
|
|
25784
|
-
const defaultGetDotenvCliOptionsLocalPath = resolve(pkgDir, 'getdotenv.config.json');
|
|
25785
|
-
/**
|
|
25786
|
-
* Local default CLI options.
|
|
25787
|
-
*
|
|
25788
|
-
* @defaultValue `{}`
|
|
25789
|
-
*/
|
|
25790
|
-
const defaultGetDotenvCliOptionsLocal = (fs$a.existsSync(defaultGetDotenvCliOptionsLocalPath)
|
|
25791
|
-
? JSON.parse(fs$a.readFileSync(defaultGetDotenvCliOptionsLocalPath).toString())
|
|
25792
|
-
: {});
|
|
25793
25723
|
|
|
25794
|
-
|
|
25795
|
-
* Merges two sets of `getDotenv` options and eliminates any falsy `vars`. `target` takes precedence.
|
|
25796
|
-
*
|
|
25797
|
-
* @param target - Target options object (takes precedence).
|
|
25798
|
-
* @param source - Source options object (provides defaults).
|
|
25799
|
-
* @returns Merged options object.
|
|
25800
|
-
*/
|
|
25801
|
-
const mergeGetDotenvOptions = (target = {}, source = {}) => ({
|
|
25802
|
-
...source,
|
|
25803
|
-
...target,
|
|
25804
|
-
shellScripts: {
|
|
25805
|
-
...(source.shellScripts ?? {}),
|
|
25806
|
-
...(target.shellScripts ?? {}),
|
|
25807
|
-
},
|
|
25808
|
-
vars: _.pickBy({
|
|
25809
|
-
...(source.vars ?? {}),
|
|
25810
|
-
...(target.vars ?? {}),
|
|
25811
|
-
}, (v) => !!v),
|
|
25812
|
-
});
|
|
25724
|
+
const getDotenvOptionsFilename = 'getdotenv.config.json';
|
|
25813
25725
|
/**
|
|
25814
25726
|
* Converts programmatic CLI options to `getDotenv` options.
|
|
25815
25727
|
*
|
|
@@ -25817,8 +25729,8 @@ const mergeGetDotenvOptions = (target = {}, source = {}) => ({
|
|
|
25817
25729
|
*
|
|
25818
25730
|
* @returns `getDotenv` options.
|
|
25819
25731
|
*/
|
|
25820
|
-
const getDotenvCliOptions2Options = ({ paths, pathsDelimiter, pathsDelimiterPattern, vars, varsAssignor, varsAssignorPattern, varsDelimiter, varsDelimiterPattern, ...rest }
|
|
25821
|
-
...rest,
|
|
25732
|
+
const getDotenvCliOptions2Options = ({ paths, pathsDelimiter, pathsDelimiterPattern, vars, varsAssignor, varsAssignorPattern, varsDelimiter, varsDelimiterPattern, ...rest }) => ({
|
|
25733
|
+
..._.omit(rest, ['debug', 'shellScripts']),
|
|
25822
25734
|
paths: paths?.split(pathsDelimiterPattern
|
|
25823
25735
|
? RegExp(pathsDelimiterPattern)
|
|
25824
25736
|
: pathsDelimiter ?? ' ') ?? [],
|
|
@@ -25830,18 +25742,20 @@ const getDotenvCliOptions2Options = ({ paths, pathsDelimiter, pathsDelimiterPatt
|
|
|
25830
25742
|
? RegExp(varsAssignorPattern)
|
|
25831
25743
|
: varsAssignor ?? '='))),
|
|
25832
25744
|
});
|
|
25833
|
-
|
|
25834
|
-
|
|
25835
|
-
|
|
25836
|
-
|
|
25837
|
-
|
|
25838
|
-
|
|
25839
|
-
|
|
25840
|
-
|
|
25841
|
-
|
|
25842
|
-
|
|
25843
|
-
|
|
25844
|
-
})
|
|
25745
|
+
const resolveGetDotenvOptions = async (customOptions) => {
|
|
25746
|
+
const localPkgDir = await packageDirectory();
|
|
25747
|
+
const localOptionsPath = localPkgDir
|
|
25748
|
+
? resolve(localPkgDir, getDotenvOptionsFilename)
|
|
25749
|
+
: undefined;
|
|
25750
|
+
const localOptions = (localOptionsPath && (await fs$a.exists(localOptionsPath))
|
|
25751
|
+
? JSON.parse((await fs$a.readFile(localOptionsPath)).toString())
|
|
25752
|
+
: {});
|
|
25753
|
+
const result = _.defaultsDeep(customOptions, getDotenvCliOptions2Options(_.defaultsDeep(localOptions, baseGetDotenvCliOptions)));
|
|
25754
|
+
return {
|
|
25755
|
+
...result,
|
|
25756
|
+
vars: _.pickBy(result.vars ?? {}, (v) => !!v),
|
|
25757
|
+
};
|
|
25758
|
+
};
|
|
25845
25759
|
|
|
25846
25760
|
var main$1 = {exports: {}};
|
|
25847
25761
|
|
|
@@ -26311,7 +26225,7 @@ const readDotenv = async (path) => {
|
|
|
26311
26225
|
*/
|
|
26312
26226
|
const getDotenv = async (options = {}) => {
|
|
26313
26227
|
// Apply defaults.
|
|
26314
|
-
const { defaultEnv, dotenvToken = '.env', dynamicPath, env, excludeDynamic = false, excludeEnv = false, excludeGlobal = false, excludePrivate = false, excludePublic = false, loadProcess = false, log = false, logger = console, outputPath, paths = [], privateToken = 'local', vars = {}, } =
|
|
26228
|
+
const { defaultEnv, dotenvToken = '.env', dynamicPath, env, excludeDynamic = false, excludeEnv = false, excludeGlobal = false, excludePrivate = false, excludePublic = false, loadProcess = false, log = false, logger = console, outputPath, paths = [], privateToken = 'local', vars = {}, } = await resolveGetDotenvOptions(options);
|
|
26315
26229
|
// Read .env files.
|
|
26316
26230
|
const loaded = paths.length
|
|
26317
26231
|
? await paths.reduce(async (e, p) => {
|
|
@@ -34192,7 +34106,7 @@ const cmdCommand$1 = new Command()
|
|
|
34192
34106
|
throw new Error(`unable to resolve parent command`);
|
|
34193
34107
|
if (!thisCommand.parent.parent)
|
|
34194
34108
|
throw new Error(`unable to resolve root command`);
|
|
34195
|
-
const {
|
|
34109
|
+
const { getDotenvCliOptions: { logger = console, shellScripts }, } = thisCommand.parent.parent;
|
|
34196
34110
|
const { ignoreErrors, globs, list, pkgCwd, rootPath } = thisCommand.parent.opts();
|
|
34197
34111
|
// Execute shell command.
|
|
34198
34112
|
{
|
|
@@ -34223,7 +34137,7 @@ const batchCommand = new Command()
|
|
|
34223
34137
|
.hook('preSubcommand', async (thisCommand) => {
|
|
34224
34138
|
if (!thisCommand.parent)
|
|
34225
34139
|
throw new Error(`unable to resolve root command`);
|
|
34226
|
-
const {
|
|
34140
|
+
const { getDotenvCliOptions: { logger = console, shellScripts }, } = thisCommand.parent;
|
|
34227
34141
|
const { command, ignoreErrors, globs, list, pkgCwd, rootPath } = thisCommand.opts();
|
|
34228
34142
|
if (command && thisCommand.args.length) {
|
|
34229
34143
|
logger.error(`--command option conflicts with cmd subcommand.`);
|
|
@@ -34254,7 +34168,7 @@ const cmdCommand = new Command()
|
|
|
34254
34168
|
return;
|
|
34255
34169
|
if (!thisCommand.parent)
|
|
34256
34170
|
throw new Error('parent command not found');
|
|
34257
|
-
const {
|
|
34171
|
+
const { getDotenvCliOptions: { debug, logger = console, shellScripts }, } = thisCommand.parent;
|
|
34258
34172
|
const command = thisCommand.args.join(' ');
|
|
34259
34173
|
const shellCommand = shellScripts?.[command] ?? command;
|
|
34260
34174
|
if (debug)
|
|
@@ -34266,19 +34180,50 @@ const cmdCommand = new Command()
|
|
|
34266
34180
|
});
|
|
34267
34181
|
|
|
34268
34182
|
/**
|
|
34269
|
-
*
|
|
34183
|
+
* Resolve `GetDotenvCliGenerateOptions` from `import.meta.url` and custom options.
|
|
34270
34184
|
*/
|
|
34271
|
-
const
|
|
34272
|
-
const
|
|
34273
|
-
...
|
|
34274
|
-
|
|
34275
|
-
|
|
34276
|
-
shellScripts: {
|
|
34277
|
-
...(defaultGetDotenvCliOptionsGlobal.shellScripts ?? {}),
|
|
34278
|
-
...(cliOptionsCustom.shellScripts ?? {}),
|
|
34279
|
-
...(defaultGetDotenvCliOptionsLocal.shellScripts ?? {}),
|
|
34280
|
-
},
|
|
34185
|
+
const resolveGetDotenvCliGenerateOptions = async ({ importMetaUrl, ...customOptions }) => {
|
|
34186
|
+
const baseOptions = {
|
|
34187
|
+
...baseGetDotenvCliOptions,
|
|
34188
|
+
alias: 'getdotenv',
|
|
34189
|
+
description: 'Base CLI.',
|
|
34281
34190
|
};
|
|
34191
|
+
const globalPkgDir = importMetaUrl
|
|
34192
|
+
? await packageDirectory({
|
|
34193
|
+
cwd: fileURLToPath$1(importMetaUrl),
|
|
34194
|
+
})
|
|
34195
|
+
: undefined;
|
|
34196
|
+
const globalOptionsPath = globalPkgDir
|
|
34197
|
+
? resolve(globalPkgDir, getDotenvOptionsFilename)
|
|
34198
|
+
: undefined;
|
|
34199
|
+
const globalOptions = (globalOptionsPath && (await fs$a.exists(globalOptionsPath))
|
|
34200
|
+
? JSON.parse((await fs$a.readFile(globalOptionsPath)).toString())
|
|
34201
|
+
: {});
|
|
34202
|
+
const localPkgDir = await packageDirectory();
|
|
34203
|
+
const localOptionsPath = localPkgDir
|
|
34204
|
+
? resolve(localPkgDir, getDotenvOptionsFilename)
|
|
34205
|
+
: undefined;
|
|
34206
|
+
const localOptions = (localOptionsPath &&
|
|
34207
|
+
localOptionsPath !== globalOptionsPath &&
|
|
34208
|
+
(await fs$a.exists(localOptionsPath))
|
|
34209
|
+
? JSON.parse((await fs$a.readFile(localOptionsPath)).toString())
|
|
34210
|
+
: {});
|
|
34211
|
+
return _.defaultsDeep(customOptions, localOptions, globalOptions, baseOptions);
|
|
34212
|
+
};
|
|
34213
|
+
|
|
34214
|
+
const resolveExclusion = (exclude, excludeOff, defaultValue) => exclude ? true : excludeOff ? undefined : defaultValue ? true : undefined;
|
|
34215
|
+
const resolveExclusionAll = (exclude, excludeOff, defaultValue, excludeAll, excludeAllOff) => excludeAll && !excludeOff
|
|
34216
|
+
? true
|
|
34217
|
+
: excludeAllOff && !exclude
|
|
34218
|
+
? undefined
|
|
34219
|
+
: defaultValue
|
|
34220
|
+
? true
|
|
34221
|
+
: undefined;
|
|
34222
|
+
/**
|
|
34223
|
+
* Generate a Commander CLI Command for get-dotenv.
|
|
34224
|
+
*/
|
|
34225
|
+
const generateGetDotenvCli = async (customOptions) => {
|
|
34226
|
+
const { alias, debug, defaultEnv, description, dotenvToken, dynamicPath, env, excludeDynamic, excludeEnv, excludeGlobal, excludePrivate, excludePublic, loadProcess, log, logger, outputPath, paths, pathsDelimiter, pathsDelimiterPattern, postHook, preHook, privateToken, shellScripts, varsAssignor, varsAssignorPattern, varsDelimiter, varsDelimiterPattern, } = await resolveGetDotenvCliGenerateOptions(customOptions);
|
|
34282
34227
|
const excludeAll = !!excludeDynamic &&
|
|
34283
34228
|
((!!excludeEnv && !!excludeGlobal) ||
|
|
34284
34229
|
(!!excludePrivate && !!excludePublic));
|
|
@@ -34331,67 +34276,50 @@ const generateGetDotenvCli = ({ logger = console, preHook, postHook, ...cliOptio
|
|
|
34331
34276
|
.addCommand(batchCommand)
|
|
34332
34277
|
.addCommand(cmdCommand, { isDefault: true })
|
|
34333
34278
|
.hook('preSubcommand', async (thisCommand) => {
|
|
34334
|
-
|
|
34335
|
-
|
|
34336
|
-
|
|
34337
|
-
|
|
34338
|
-
|
|
34339
|
-
|
|
34340
|
-
|
|
34341
|
-
|
|
34342
|
-
|
|
34343
|
-
|
|
34279
|
+
// Get parent command GetDotenvCliOptions.
|
|
34280
|
+
const parentGetDotenvCliOptions = process.env.getDotenvCliOptions
|
|
34281
|
+
? JSON.parse(process.env.getDotenvCliOptions)
|
|
34282
|
+
: undefined;
|
|
34283
|
+
// Get raw CLI options from commander.
|
|
34284
|
+
const rawCliOptions = thisCommand.opts();
|
|
34285
|
+
// Extract current GetDotenvCliOptions from raw CLI options.
|
|
34286
|
+
const { command, debugOff, excludeAll, excludeAllOff, excludeDynamicOff, excludeEnvOff, excludeGlobalOff, excludePrivateOff, excludePublicOff, loadProcessOff, logOff, shellScripts, ...rawCliOptionsRest } = rawCliOptions;
|
|
34287
|
+
const currentGetDotenvCliOptions = rawCliOptionsRest;
|
|
34288
|
+
if (shellScripts)
|
|
34289
|
+
currentGetDotenvCliOptions.shellScripts = JSON.parse(shellScripts);
|
|
34290
|
+
// Merge current & parent GetDotenvCliOptions.
|
|
34291
|
+
const mergedGetDotenvCliOptions = _.defaultsDeep(currentGetDotenvCliOptions, parentGetDotenvCliOptions ?? {});
|
|
34344
34292
|
// Resolve flags.
|
|
34345
|
-
|
|
34346
|
-
|
|
34347
|
-
|
|
34348
|
-
|
|
34349
|
-
|
|
34350
|
-
|
|
34351
|
-
|
|
34352
|
-
|
|
34353
|
-
|
|
34354
|
-
|
|
34355
|
-
|
|
34356
|
-
|
|
34357
|
-
|
|
34358
|
-
|
|
34359
|
-
|
|
34360
|
-
|
|
34361
|
-
|
|
34362
|
-
cliOptions.excludeGlobal = resolveExclusionAll(cliOptions.excludeGlobal, excludeGlobalOff, excludeGlobal);
|
|
34363
|
-
cliOptions.excludePrivate = resolveExclusionAll(cliOptions.excludePrivate, excludePrivateOff, excludePrivate);
|
|
34364
|
-
cliOptions.excludePublic = resolveExclusionAll(cliOptions.excludePublic, excludePublicOff, excludePublic);
|
|
34365
|
-
cliOptions.log = resolveExclusion(cliOptions.log, logOff, log);
|
|
34366
|
-
cliOptions.loadProcess = resolveExclusion(cliOptions.loadProcess, loadProcessOff, loadProcess);
|
|
34367
|
-
if (cliOptions.debug)
|
|
34368
|
-
logger.log('\n*** cli options after default resolution ***\n', {
|
|
34369
|
-
cliOptions,
|
|
34293
|
+
mergedGetDotenvCliOptions.debug = resolveExclusion(mergedGetDotenvCliOptions.debug, debugOff, debug);
|
|
34294
|
+
mergedGetDotenvCliOptions.excludeDynamic = resolveExclusionAll(mergedGetDotenvCliOptions.excludeDynamic, excludeDynamicOff, excludeDynamic, excludeAll, excludeAllOff);
|
|
34295
|
+
mergedGetDotenvCliOptions.excludeEnv = resolveExclusionAll(mergedGetDotenvCliOptions.excludeEnv, excludeEnvOff, excludeEnv, excludeAll, excludeAllOff);
|
|
34296
|
+
mergedGetDotenvCliOptions.excludeGlobal = resolveExclusionAll(mergedGetDotenvCliOptions.excludeGlobal, excludeGlobalOff, excludeGlobal, excludeAll, excludeAllOff);
|
|
34297
|
+
mergedGetDotenvCliOptions.excludePrivate = resolveExclusionAll(mergedGetDotenvCliOptions.excludePrivate, excludePrivateOff, excludePrivate, excludeAll, excludeAllOff);
|
|
34298
|
+
mergedGetDotenvCliOptions.excludePublic = resolveExclusionAll(mergedGetDotenvCliOptions.excludePublic, excludePublicOff, excludePublic, excludeAll, excludeAllOff);
|
|
34299
|
+
mergedGetDotenvCliOptions.log = resolveExclusion(mergedGetDotenvCliOptions.log, logOff, log);
|
|
34300
|
+
mergedGetDotenvCliOptions.loadProcess = resolveExclusion(mergedGetDotenvCliOptions.loadProcess, loadProcessOff, loadProcess);
|
|
34301
|
+
if (mergedGetDotenvCliOptions.debug && parentGetDotenvCliOptions)
|
|
34302
|
+
logger.debug('\n*** parent command GetDotenvCliOptions ***\n', parentGetDotenvCliOptions);
|
|
34303
|
+
if (mergedGetDotenvCliOptions.debug)
|
|
34304
|
+
logger.debug('\n*** current command raw options ***\n', rawCliOptions);
|
|
34305
|
+
if (mergedGetDotenvCliOptions.debug)
|
|
34306
|
+
logger.debug('\n*** current command GetDotenvCliOptions ***\n', currentGetDotenvCliOptions);
|
|
34307
|
+
if (mergedGetDotenvCliOptions.debug)
|
|
34308
|
+
logger.debug('\n*** merged GetDotenvCliOptions ***\n', {
|
|
34309
|
+
mergedGetDotenvCliOptions,
|
|
34370
34310
|
});
|
|
34371
34311
|
// Execute pre-hook.
|
|
34372
34312
|
if (preHook) {
|
|
34373
|
-
await preHook(
|
|
34374
|
-
if (
|
|
34375
|
-
logger.
|
|
34313
|
+
await preHook(mergedGetDotenvCliOptions);
|
|
34314
|
+
if (mergedGetDotenvCliOptions.debug)
|
|
34315
|
+
logger.debug('\n*** GetDotenvCliOptions after pre-hook ***\n', mergedGetDotenvCliOptions);
|
|
34376
34316
|
}
|
|
34377
|
-
//
|
|
34378
|
-
|
|
34379
|
-
? JSON.parse(process.env.getDotenvOptions)
|
|
34380
|
-
: {});
|
|
34381
|
-
const cliGetDotenvOptions = getDotenvCliOptions2Options(cliOptions);
|
|
34382
|
-
const getDotenvOptions = mergeGetDotenvOptions(cliGetDotenvOptions, parentGetdotenvOptions);
|
|
34383
|
-
if (cliOptions.debug)
|
|
34384
|
-
logger.log('\n*** getdotenv option resolution ***\n', {
|
|
34385
|
-
parentGetdotenvOptions,
|
|
34386
|
-
cliGetDotenvOptions,
|
|
34387
|
-
getDotenvOptions,
|
|
34388
|
-
});
|
|
34317
|
+
// Persist GetDotenvCliOptions in command for subcommand access.
|
|
34318
|
+
_.set(thisCommand, 'getDotenvCliOptions', mergedGetDotenvCliOptions);
|
|
34389
34319
|
// Execute getdotenv.
|
|
34390
|
-
const
|
|
34391
|
-
|
|
34392
|
-
|
|
34393
|
-
if (cliOptions.debug)
|
|
34394
|
-
logger.log('\n*** resulting dotenv values ***\n', { dotenv });
|
|
34320
|
+
const dotenv = await getDotenv(getDotenvCliOptions2Options(mergedGetDotenvCliOptions));
|
|
34321
|
+
if (mergedGetDotenvCliOptions.debug)
|
|
34322
|
+
logger.debug('\n*** getDotenv output ***\n', dotenv);
|
|
34395
34323
|
// Execute post-hook.
|
|
34396
34324
|
if (postHook)
|
|
34397
34325
|
await postHook(dotenv);
|
|
@@ -34401,13 +34329,13 @@ const generateGetDotenvCli = ({ logger = console, preHook, postHook, ...cliOptio
|
|
|
34401
34329
|
process.exit(0);
|
|
34402
34330
|
}
|
|
34403
34331
|
if (command) {
|
|
34404
|
-
const shellCommand =
|
|
34405
|
-
if (
|
|
34406
|
-
logger.
|
|
34332
|
+
const shellCommand = mergedGetDotenvCliOptions.shellScripts?.[command] ?? command;
|
|
34333
|
+
if (mergedGetDotenvCliOptions.debug)
|
|
34334
|
+
logger.debug('\n*** shell command ***\n', shellCommand);
|
|
34407
34335
|
await execaCommand(shellCommand, {
|
|
34408
34336
|
env: {
|
|
34409
34337
|
...process.env,
|
|
34410
|
-
|
|
34338
|
+
getDotenvCliOptions: JSON.stringify(_.omit(mergedGetDotenvCliOptions, ['logger'])),
|
|
34411
34339
|
},
|
|
34412
34340
|
shell: true,
|
|
34413
34341
|
stdio: 'inherit',
|
|
@@ -34416,5 +34344,5 @@ const generateGetDotenvCli = ({ logger = console, preHook, postHook, ...cliOptio
|
|
|
34416
34344
|
});
|
|
34417
34345
|
};
|
|
34418
34346
|
|
|
34419
|
-
const cli = generateGetDotenvCli();
|
|
34347
|
+
const cli = await generateGetDotenvCli({ importMetaUrl: import.meta.url });
|
|
34420
34348
|
await cli.parseAsync();
|