@karmaniverous/get-dotenv 3.1.6 → 3.1.8
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
|
@@ -7,7 +7,7 @@ Load environment variables with a cascade of environment-aware dotenv files. You
|
|
|
7
7
|
- Define dynamic variables progressively in terms of other variables and other logic.
|
|
8
8
|
- Exclude public, private, global, environment-specific, or dynamic variables.
|
|
9
9
|
- Specify explicit variables to include.
|
|
10
|
-
- Extract the resulting variables to an object, `process.env`, a dotenv file, or a logger, in any combination.
|
|
10
|
+
- Extract the resulting variables to an object, `process.env`, a dotenv file, or a logger object, in any combination.
|
|
11
11
|
- Execute a shell command within the resulting environment. You can even nest additional `getdotenv` calls!
|
|
12
12
|
- Specify the directories containing your dotenv files.
|
|
13
13
|
- Specify the filename token that identifies dotenv files (e.g. '.env').
|
|
@@ -235,7 +235,7 @@ get-dotenv options type
|
|
|
235
235
|
| [excludePublic] | <code>bool</code> | exclude public variables |
|
|
236
236
|
| [loadProcess] | <code>bool</code> | load dotenv to process.env |
|
|
237
237
|
| [log] | <code>bool</code> | log result to logger |
|
|
238
|
-
| [logger] | <code>function</code> | logger
|
|
238
|
+
| [logger] | <code>function</code> | logger object (defaults to console) |
|
|
239
239
|
| [outputPath] | <code>string</code> | if populated, writes consolidated .env file to this path (follows [dotenv-expand rules](https://github.com/motdotla/dotenv-expand/blob/master/tests/.env)) |
|
|
240
240
|
| [paths] | <code>Array.<string></code> | array of input directory paths |
|
|
241
241
|
| [privateToken] | <code>string</code> | token indicating private variables |
|
package/bin/getdotenv/index.js
CHANGED
|
@@ -35,7 +35,7 @@ const pruneVars = (getdotenvDefaultOptions, options) => (0, _lodash.default)({
|
|
|
35
35
|
* @property {bool} [excludePublic] - exclude public variables
|
|
36
36
|
* @property {bool} [loadProcess] - load dotenv to process.env
|
|
37
37
|
* @property {bool} [log] - log result to logger
|
|
38
|
-
* @property {function} [logger] - logger
|
|
38
|
+
* @property {function} [logger] - logger object (defaults to console)
|
|
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] - array of input directory paths
|
|
41
41
|
* @property {string} [privateToken] - token indicating private variables
|
|
@@ -66,7 +66,7 @@ const getDotenv = async function () {
|
|
|
66
66
|
excludePublic,
|
|
67
67
|
loadProcess,
|
|
68
68
|
log,
|
|
69
|
-
logger = console
|
|
69
|
+
logger = console,
|
|
70
70
|
outputPath,
|
|
71
71
|
paths,
|
|
72
72
|
privateToken
|
|
@@ -128,7 +128,7 @@ const getDotenv = async function () {
|
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
// Log result.
|
|
131
|
-
if (log) logger(dotenv);
|
|
131
|
+
if (log) logger.log(dotenv);
|
|
132
132
|
|
|
133
133
|
// Load process.env.
|
|
134
134
|
if (loadProcess) Object.assign(process.env, dotenv);
|
|
@@ -159,7 +159,7 @@ const getDotenvSync = function () {
|
|
|
159
159
|
excludePublic,
|
|
160
160
|
loadProcess,
|
|
161
161
|
log,
|
|
162
|
-
logger = console
|
|
162
|
+
logger = console,
|
|
163
163
|
outputPath,
|
|
164
164
|
paths,
|
|
165
165
|
privateToken
|
|
@@ -220,7 +220,7 @@ const getDotenvSync = function () {
|
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
// Log result.
|
|
223
|
-
if (log) logger(dotenv);
|
|
223
|
+
if (log) logger.log(dotenv);
|
|
224
224
|
|
|
225
225
|
// Load process.env.
|
|
226
226
|
if (loadProcess) Object.assign(process.env, dotenv);
|
|
@@ -66,7 +66,7 @@ var _options = require("./options.js");
|
|
|
66
66
|
*/
|
|
67
67
|
const getDotenvCli = function () {
|
|
68
68
|
let {
|
|
69
|
-
logger = console
|
|
69
|
+
logger = console,
|
|
70
70
|
preHook,
|
|
71
71
|
postHook,
|
|
72
72
|
...cliOptionsCustom
|
|
@@ -104,10 +104,10 @@ const getDotenvCli = function () {
|
|
|
104
104
|
const excludeAll = excludeDynamic && (excludeEnv && excludeGlobal || excludePrivate && excludePublic);
|
|
105
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({
|
|
106
106
|
showGlobalOptions: true
|
|
107
|
-
}).enablePositionalOptions().passThroughOptions().action(async (options,
|
|
108
|
-
|
|
107
|
+
}).enablePositionalOptions().passThroughOptions().action(async (options, command) => {
|
|
108
|
+
const {
|
|
109
109
|
args
|
|
110
|
-
} =
|
|
110
|
+
} = command;
|
|
111
111
|
if (args.length) await (0, _execa.execaCommand)(args.join('\\ '), {
|
|
112
112
|
stdio: 'inherit',
|
|
113
113
|
shell: true
|
|
@@ -116,7 +116,7 @@ const getDotenvCli = function () {
|
|
|
116
116
|
isDefault: true
|
|
117
117
|
}).hook('preSubcommand', async thisCommand => {
|
|
118
118
|
const rawOptions = thisCommand.opts();
|
|
119
|
-
if (rawOptions.debug) logger('\n*** raw cli options ***\n', {
|
|
119
|
+
if (rawOptions.debug) logger.log('\n*** raw cli options ***\n', {
|
|
120
120
|
rawOptions
|
|
121
121
|
});
|
|
122
122
|
|
|
@@ -146,14 +146,14 @@ const getDotenvCli = function () {
|
|
|
146
146
|
cliOptions.excludePublic = resolveExclusionAll(cliOptions.excludePublic, excludePublicOff, excludePublic);
|
|
147
147
|
cliOptions.log = resolveExclusion(cliOptions.log, logOff, log);
|
|
148
148
|
cliOptions.loadProcess = resolveExclusion(cliOptions.loadProcess, loadProcessOff, loadProcess);
|
|
149
|
-
if (cliOptions.debug) logger('\n*** cli options after default resolution ***\n', {
|
|
149
|
+
if (cliOptions.debug) logger.log('\n*** cli options after default resolution ***\n', {
|
|
150
150
|
cliOptions
|
|
151
151
|
});
|
|
152
152
|
|
|
153
153
|
// Execute pre-hook.
|
|
154
154
|
if (preHook) {
|
|
155
155
|
cliOptions = (await preHook(cliOptions)) ?? cliOptions;
|
|
156
|
-
if (cliOptions.debug) logger('\n*** cli options after pre-hook ***\n', cliOptions);
|
|
156
|
+
if (cliOptions.debug) logger.log('\n*** cli options after pre-hook ***\n', cliOptions);
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
// Get getdotenv options from parent command.
|
|
@@ -163,7 +163,7 @@ const getDotenvCli = function () {
|
|
|
163
163
|
...parentGetdotenvOptions,
|
|
164
164
|
...cliGetdotenvOptions
|
|
165
165
|
};
|
|
166
|
-
if (cliOptions.debug) logger('\n*** getdotenv option resolution ***\n', {
|
|
166
|
+
if (cliOptions.debug) logger.log('\n*** getdotenv option resolution ***\n', {
|
|
167
167
|
parentGetdotenvOptions,
|
|
168
168
|
cliGetdotenvOptions,
|
|
169
169
|
getdotenvOptions
|
package/lib/getDotenv.js
CHANGED
|
@@ -32,7 +32,7 @@ const pruneVars = (getdotenvDefaultOptions, options) =>
|
|
|
32
32
|
* @property {bool} [excludePublic] - exclude public variables
|
|
33
33
|
* @property {bool} [loadProcess] - load dotenv to process.env
|
|
34
34
|
* @property {bool} [log] - log result to logger
|
|
35
|
-
* @property {function} [logger] - logger
|
|
35
|
+
* @property {function} [logger] - logger object (defaults to console)
|
|
36
36
|
* @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})
|
|
37
37
|
* @property {string[]} [paths] - array of input directory paths
|
|
38
38
|
* @property {string} [privateToken] - token indicating private variables
|
|
@@ -62,7 +62,7 @@ export const getDotenv = async (options = {}) => {
|
|
|
62
62
|
excludePublic,
|
|
63
63
|
loadProcess,
|
|
64
64
|
log,
|
|
65
|
-
logger = console
|
|
65
|
+
logger = console,
|
|
66
66
|
outputPath,
|
|
67
67
|
paths,
|
|
68
68
|
privateToken,
|
|
@@ -145,7 +145,7 @@ export const getDotenv = async (options = {}) => {
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
// Log result.
|
|
148
|
-
if (log) logger(dotenv);
|
|
148
|
+
if (log) logger.log(dotenv);
|
|
149
149
|
|
|
150
150
|
// Load process.env.
|
|
151
151
|
if (loadProcess) Object.assign(process.env, dotenv);
|
|
@@ -175,7 +175,7 @@ export const getDotenvSync = (options = {}) => {
|
|
|
175
175
|
excludePublic,
|
|
176
176
|
loadProcess,
|
|
177
177
|
log,
|
|
178
|
-
logger = console
|
|
178
|
+
logger = console,
|
|
179
179
|
outputPath,
|
|
180
180
|
paths,
|
|
181
181
|
privateToken,
|
|
@@ -256,7 +256,7 @@ export const getDotenvSync = (options = {}) => {
|
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
// Log result.
|
|
259
|
-
if (log) logger(dotenv);
|
|
259
|
+
if (log) logger.log(dotenv);
|
|
260
260
|
|
|
261
261
|
// Load process.env.
|
|
262
262
|
if (loadProcess) Object.assign(process.env, dotenv);
|
package/lib/getDotenvCli.js
CHANGED
|
@@ -63,7 +63,7 @@ import {
|
|
|
63
63
|
* @returns {object} The CLI command.
|
|
64
64
|
*/
|
|
65
65
|
export const getDotenvCli = ({
|
|
66
|
-
logger = console
|
|
66
|
+
logger = console,
|
|
67
67
|
preHook,
|
|
68
68
|
postHook,
|
|
69
69
|
...cliOptionsCustom
|
|
@@ -326,7 +326,8 @@ export const getDotenvCli = ({
|
|
|
326
326
|
.configureHelp({ showGlobalOptions: true })
|
|
327
327
|
.enablePositionalOptions()
|
|
328
328
|
.passThroughOptions()
|
|
329
|
-
.action(async (options,
|
|
329
|
+
.action(async (options, command) => {
|
|
330
|
+
const { args } = command;
|
|
330
331
|
if (args.length)
|
|
331
332
|
await execaCommand(args.join('\\ '), {
|
|
332
333
|
stdio: 'inherit',
|
|
@@ -339,7 +340,7 @@ export const getDotenvCli = ({
|
|
|
339
340
|
const rawOptions = thisCommand.opts();
|
|
340
341
|
|
|
341
342
|
if (rawOptions.debug)
|
|
342
|
-
logger('\n*** raw cli options ***\n', { rawOptions });
|
|
343
|
+
logger.log('\n*** raw cli options ***\n', { rawOptions });
|
|
343
344
|
|
|
344
345
|
// Load options.
|
|
345
346
|
let {
|
|
@@ -408,7 +409,7 @@ export const getDotenvCli = ({
|
|
|
408
409
|
);
|
|
409
410
|
|
|
410
411
|
if (cliOptions.debug)
|
|
411
|
-
logger('\n*** cli options after default resolution ***\n', {
|
|
412
|
+
logger.log('\n*** cli options after default resolution ***\n', {
|
|
412
413
|
cliOptions,
|
|
413
414
|
});
|
|
414
415
|
|
|
@@ -416,7 +417,7 @@ export const getDotenvCli = ({
|
|
|
416
417
|
if (preHook) {
|
|
417
418
|
cliOptions = (await preHook(cliOptions)) ?? cliOptions;
|
|
418
419
|
if (cliOptions.debug)
|
|
419
|
-
logger('\n*** cli options after pre-hook ***\n', cliOptions);
|
|
420
|
+
logger.log('\n*** cli options after pre-hook ***\n', cliOptions);
|
|
420
421
|
}
|
|
421
422
|
|
|
422
423
|
// Get getdotenv options from parent command.
|
|
@@ -432,7 +433,7 @@ export const getDotenvCli = ({
|
|
|
432
433
|
};
|
|
433
434
|
|
|
434
435
|
if (cliOptions.debug)
|
|
435
|
-
logger('\n*** getdotenv option resolution ***\n', {
|
|
436
|
+
logger.log('\n*** getdotenv option resolution ***\n', {
|
|
436
437
|
parentGetdotenvOptions,
|
|
437
438
|
cliGetdotenvOptions,
|
|
438
439
|
getdotenvOptions,
|