@karmaniverous/get-dotenv 4.2.3 → 4.3.0
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 +21 -2
- package/dist/getdotenv.cli.mjs +6 -7
- package/dist/index.cjs +5 -5
- package/dist/index.d.cts +9 -1
- package/dist/index.d.mts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.mjs +7 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -60,7 +60,7 @@ See the [GetDotenvOptions](./src/GetDotenvOptions.ts) type for descriptions of a
|
|
|
60
60
|
|
|
61
61
|
This package supports the full [`dotenv-expand`](https://www.npmjs.com/package/dotenv-expand) syntax, with some internal performance improvements.
|
|
62
62
|
|
|
63
|
-
Use the `dynamicPath` option to add a relative path to a Javascript
|
|
63
|
+
Use the `dynamicPath` option to add a relative path to a Javascript module with a default export like this:
|
|
64
64
|
|
|
65
65
|
```js
|
|
66
66
|
export default {
|
|
@@ -72,10 +72,29 @@ export default {
|
|
|
72
72
|
};
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
-
If the value corresponding to a key is a function, it will be executed with the current state of `dotenv` as its single argument and the result applied back to the `dotenv` object. Otherwise, the value will just be applied back to `dotenv`.
|
|
75
|
+
If the value corresponding to a key is a function, it will be executed with the current state of `dotenv` as its single argument and the result applied back to the `dotenv` object. Otherwise, the value will just be applied back to `dotenv`. (Although if you're going to do that then you might as well just create a public global variable in the first place.)
|
|
76
76
|
|
|
77
77
|
Since keys will be evaluated progressively, each successive key function will have access to any previous ones. These keys can also override existing variables.
|
|
78
78
|
|
|
79
|
+
### Dynamic Processing with TypeScript
|
|
80
|
+
|
|
81
|
+
Even though the rest of your project is in TypeScript, the dynamic processing module SHOULD be in JavasScript.
|
|
82
|
+
|
|
83
|
+
Think about it: the module is loaded via a dynamic import, with the file name determined at run time. You will have to jump through some hoops to get your bundler to compile this file, and you'll have to be careful to set `dynamicPath` to reference the compiled file. That's a lot of work for some very simple log.
|
|
84
|
+
|
|
85
|
+
BUT... if you must, then your dynamic module's default export should be of the `GetDotenvDynamic` type, which is defined [here](./src/GetDotenvOptions.ts) and looks like this:
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
export type ProcessEnv = Record<string, string | undefined>;
|
|
89
|
+
|
|
90
|
+
export type GetDotenvDynamicFunction = (vars: ProcessEnv) => string | undefined;
|
|
91
|
+
|
|
92
|
+
export type GetDotenvDynamic = Record<
|
|
93
|
+
string,
|
|
94
|
+
GetDotenvDynamicFunction | ReturnType<GetDotenvDynamicFunction>
|
|
95
|
+
>;
|
|
96
|
+
```
|
|
97
|
+
|
|
79
98
|
## Command Line Interface
|
|
80
99
|
|
|
81
100
|
You can also use `getdotenv` from the command line:
|
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 from 'path';
|
|
4
|
+
import require$$0$1, { join } from 'path';
|
|
5
5
|
import require$$0$2 from 'fs';
|
|
6
6
|
import require$$4$1 from 'process';
|
|
7
7
|
import { fileURLToPath } from 'node:url';
|
|
@@ -23,7 +23,7 @@ import require$$0$4 from 'stream';
|
|
|
23
23
|
import require$$0$5 from 'util';
|
|
24
24
|
import require$$5 from 'assert';
|
|
25
25
|
import { webcrypto } from 'node:crypto';
|
|
26
|
-
import url, {
|
|
26
|
+
import url, { fileURLToPath as fileURLToPath$1 } from 'url';
|
|
27
27
|
import fsPromises from 'node:fs/promises';
|
|
28
28
|
import require$$2 from 'os';
|
|
29
29
|
import require$$3 from 'crypto';
|
|
@@ -30905,7 +30905,7 @@ const getDotenvCliOptions2Options = ({ paths, pathsDelimiter, pathsDelimiterPatt
|
|
|
30905
30905
|
const resolveGetDotenvOptions = async (customOptions) => {
|
|
30906
30906
|
const localPkgDir = await packageDirectory();
|
|
30907
30907
|
const localOptionsPath = localPkgDir
|
|
30908
|
-
?
|
|
30908
|
+
? join(localPkgDir, getDotenvOptionsFilename)
|
|
30909
30909
|
: undefined;
|
|
30910
30910
|
const localOptions = (localOptionsPath && (await fs$a.exists(localOptionsPath))
|
|
30911
30911
|
? JSON.parse((await fs$a.readFile(localOptionsPath)).toString())
|
|
@@ -39227,7 +39227,6 @@ const execShellCommandBatch = async ({ command, globs, ignoreErrors, list, logge
|
|
|
39227
39227
|
logger.info(headerRootPath);
|
|
39228
39228
|
logger.info(headerGlobs);
|
|
39229
39229
|
logger.info(headerCommand);
|
|
39230
|
-
logger.info('');
|
|
39231
39230
|
for (const path of paths) {
|
|
39232
39231
|
// Write path and command to console.
|
|
39233
39232
|
const pathLabel = `CWD: ${path}`;
|
|
@@ -39238,7 +39237,7 @@ const execShellCommandBatch = async ({ command, globs, ignoreErrors, list, logge
|
|
|
39238
39237
|
logger.info('');
|
|
39239
39238
|
logger.info('*'.repeat(pathLabel.length));
|
|
39240
39239
|
logger.info(pathLabel);
|
|
39241
|
-
logger.info(
|
|
39240
|
+
logger.info(headerCommand);
|
|
39242
39241
|
// Execute shell command.
|
|
39243
39242
|
try {
|
|
39244
39243
|
await execaCommand(command, {
|
|
@@ -39354,14 +39353,14 @@ const resolveGetDotenvCliGenerateOptions = async ({ importMetaUrl, ...customOpti
|
|
|
39354
39353
|
})
|
|
39355
39354
|
: undefined;
|
|
39356
39355
|
const globalOptionsPath = globalPkgDir
|
|
39357
|
-
?
|
|
39356
|
+
? join(globalPkgDir, getDotenvOptionsFilename)
|
|
39358
39357
|
: undefined;
|
|
39359
39358
|
const globalOptions = (globalOptionsPath && (await fs$a.exists(globalOptionsPath))
|
|
39360
39359
|
? JSON.parse((await fs$a.readFile(globalOptionsPath)).toString())
|
|
39361
39360
|
: {});
|
|
39362
39361
|
const localPkgDir = await packageDirectory();
|
|
39363
39362
|
const localOptionsPath = localPkgDir
|
|
39364
|
-
?
|
|
39363
|
+
? join(localPkgDir, getDotenvOptionsFilename)
|
|
39365
39364
|
: undefined;
|
|
39366
39365
|
const localOptions = (localOptionsPath &&
|
|
39367
39366
|
localOptionsPath !== globalOptionsPath &&
|
package/dist/index.cjs
CHANGED
|
@@ -30906,7 +30906,7 @@ const getDotenvCliOptions2Options = ({ paths, pathsDelimiter, pathsDelimiterPatt
|
|
|
30906
30906
|
const resolveGetDotenvOptions = async (customOptions) => {
|
|
30907
30907
|
const localPkgDir = await packageDirectory();
|
|
30908
30908
|
const localOptionsPath = localPkgDir
|
|
30909
|
-
?
|
|
30909
|
+
? require$$0$1.join(localPkgDir, getDotenvOptionsFilename)
|
|
30910
30910
|
: undefined;
|
|
30911
30911
|
const localOptions = (localOptionsPath && (await fs$a.exists(localOptionsPath))
|
|
30912
30912
|
? JSON.parse((await fs$a.readFile(localOptionsPath)).toString())
|
|
@@ -39228,7 +39228,6 @@ const execShellCommandBatch = async ({ command, globs, ignoreErrors, list, logge
|
|
|
39228
39228
|
logger.info(headerRootPath);
|
|
39229
39229
|
logger.info(headerGlobs);
|
|
39230
39230
|
logger.info(headerCommand);
|
|
39231
|
-
logger.info('');
|
|
39232
39231
|
for (const path of paths) {
|
|
39233
39232
|
// Write path and command to console.
|
|
39234
39233
|
const pathLabel = `CWD: ${path}`;
|
|
@@ -39239,7 +39238,7 @@ const execShellCommandBatch = async ({ command, globs, ignoreErrors, list, logge
|
|
|
39239
39238
|
logger.info('');
|
|
39240
39239
|
logger.info('*'.repeat(pathLabel.length));
|
|
39241
39240
|
logger.info(pathLabel);
|
|
39242
|
-
logger.info(
|
|
39241
|
+
logger.info(headerCommand);
|
|
39243
39242
|
// Execute shell command.
|
|
39244
39243
|
try {
|
|
39245
39244
|
await execaCommand(command, {
|
|
@@ -39355,14 +39354,14 @@ const resolveGetDotenvCliGenerateOptions = async ({ importMetaUrl, ...customOpti
|
|
|
39355
39354
|
})
|
|
39356
39355
|
: undefined;
|
|
39357
39356
|
const globalOptionsPath = globalPkgDir
|
|
39358
|
-
?
|
|
39357
|
+
? require$$0$1.join(globalPkgDir, getDotenvOptionsFilename)
|
|
39359
39358
|
: undefined;
|
|
39360
39359
|
const globalOptions = (globalOptionsPath && (await fs$a.exists(globalOptionsPath))
|
|
39361
39360
|
? JSON.parse((await fs$a.readFile(globalOptionsPath)).toString())
|
|
39362
39361
|
: {});
|
|
39363
39362
|
const localPkgDir = await packageDirectory();
|
|
39364
39363
|
const localOptionsPath = localPkgDir
|
|
39365
|
-
?
|
|
39364
|
+
? require$$0$1.join(localPkgDir, getDotenvOptionsFilename)
|
|
39366
39365
|
: undefined;
|
|
39367
39366
|
const localOptions = (localOptionsPath &&
|
|
39368
39367
|
localOptionsPath !== globalOptionsPath &&
|
|
@@ -39510,3 +39509,4 @@ exports.dotenvExpandAll = dotenvExpandAll;
|
|
|
39510
39509
|
exports.dotenvExpandFromProcessEnv = dotenvExpandFromProcessEnv;
|
|
39511
39510
|
exports.generateGetDotenvCli = generateGetDotenvCli;
|
|
39512
39511
|
exports.getDotenv = getDotenv;
|
|
39512
|
+
exports.getDotenvCliOptions2Options = getDotenvCliOptions2Options;
|
package/dist/index.d.cts
CHANGED
|
@@ -126,6 +126,14 @@ interface GetDotenvOptions {
|
|
|
126
126
|
*/
|
|
127
127
|
vars?: ProcessEnv;
|
|
128
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* Converts programmatic CLI options to `getDotenv` options.
|
|
131
|
+
*
|
|
132
|
+
* @param cliOptions - CLI options. Defaults to `{}`.
|
|
133
|
+
*
|
|
134
|
+
* @returns `getDotenv` options.
|
|
135
|
+
*/
|
|
136
|
+
declare const getDotenvCliOptions2Options: ({ paths, pathsDelimiter, pathsDelimiterPattern, vars, varsAssignor, varsAssignorPattern, varsDelimiter, varsDelimiterPattern, ...rest }: GetDotenvCliOptions) => GetDotenvOptions;
|
|
129
137
|
|
|
130
138
|
/**
|
|
131
139
|
* Recursively expands environment variables in a string. Variables may be
|
|
@@ -220,4 +228,4 @@ declare const generateGetDotenvCli: (customOptions: Pick<GetDotenvCliGenerateOpt
|
|
|
220
228
|
*/
|
|
221
229
|
declare const getDotenv: (options?: Partial<GetDotenvOptions>) => Promise<ProcessEnv>;
|
|
222
230
|
|
|
223
|
-
export { type GetDotenvDynamic, type GetDotenvOptions, type ProcessEnv, dotenvExpand, dotenvExpandAll, dotenvExpandFromProcessEnv, generateGetDotenvCli, getDotenv };
|
|
231
|
+
export { type GetDotenvDynamic, type GetDotenvOptions, type ProcessEnv, dotenvExpand, dotenvExpandAll, dotenvExpandFromProcessEnv, generateGetDotenvCli, getDotenv, getDotenvCliOptions2Options };
|
package/dist/index.d.mts
CHANGED
|
@@ -126,6 +126,14 @@ interface GetDotenvOptions {
|
|
|
126
126
|
*/
|
|
127
127
|
vars?: ProcessEnv;
|
|
128
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* Converts programmatic CLI options to `getDotenv` options.
|
|
131
|
+
*
|
|
132
|
+
* @param cliOptions - CLI options. Defaults to `{}`.
|
|
133
|
+
*
|
|
134
|
+
* @returns `getDotenv` options.
|
|
135
|
+
*/
|
|
136
|
+
declare const getDotenvCliOptions2Options: ({ paths, pathsDelimiter, pathsDelimiterPattern, vars, varsAssignor, varsAssignorPattern, varsDelimiter, varsDelimiterPattern, ...rest }: GetDotenvCliOptions) => GetDotenvOptions;
|
|
129
137
|
|
|
130
138
|
/**
|
|
131
139
|
* Recursively expands environment variables in a string. Variables may be
|
|
@@ -220,4 +228,4 @@ declare const generateGetDotenvCli: (customOptions: Pick<GetDotenvCliGenerateOpt
|
|
|
220
228
|
*/
|
|
221
229
|
declare const getDotenv: (options?: Partial<GetDotenvOptions>) => Promise<ProcessEnv>;
|
|
222
230
|
|
|
223
|
-
export { type GetDotenvDynamic, type GetDotenvOptions, type ProcessEnv, dotenvExpand, dotenvExpandAll, dotenvExpandFromProcessEnv, generateGetDotenvCli, getDotenv };
|
|
231
|
+
export { type GetDotenvDynamic, type GetDotenvOptions, type ProcessEnv, dotenvExpand, dotenvExpandAll, dotenvExpandFromProcessEnv, generateGetDotenvCli, getDotenv, getDotenvCliOptions2Options };
|
package/dist/index.d.ts
CHANGED
|
@@ -126,6 +126,14 @@ interface GetDotenvOptions {
|
|
|
126
126
|
*/
|
|
127
127
|
vars?: ProcessEnv;
|
|
128
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* Converts programmatic CLI options to `getDotenv` options.
|
|
131
|
+
*
|
|
132
|
+
* @param cliOptions - CLI options. Defaults to `{}`.
|
|
133
|
+
*
|
|
134
|
+
* @returns `getDotenv` options.
|
|
135
|
+
*/
|
|
136
|
+
declare const getDotenvCliOptions2Options: ({ paths, pathsDelimiter, pathsDelimiterPattern, vars, varsAssignor, varsAssignorPattern, varsDelimiter, varsDelimiterPattern, ...rest }: GetDotenvCliOptions) => GetDotenvOptions;
|
|
129
137
|
|
|
130
138
|
/**
|
|
131
139
|
* Recursively expands environment variables in a string. Variables may be
|
|
@@ -220,4 +228,4 @@ declare const generateGetDotenvCli: (customOptions: Pick<GetDotenvCliGenerateOpt
|
|
|
220
228
|
*/
|
|
221
229
|
declare const getDotenv: (options?: Partial<GetDotenvOptions>) => Promise<ProcessEnv>;
|
|
222
230
|
|
|
223
|
-
export { type GetDotenvDynamic, type GetDotenvOptions, type ProcessEnv, dotenvExpand, dotenvExpandAll, dotenvExpandFromProcessEnv, generateGetDotenvCli, getDotenv };
|
|
231
|
+
export { type GetDotenvDynamic, type GetDotenvOptions, type ProcessEnv, dotenvExpand, dotenvExpandAll, dotenvExpandFromProcessEnv, generateGetDotenvCli, getDotenv, getDotenvCliOptions2Options };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import require$$0 from 'events';
|
|
2
2
|
import require$$1 from 'child_process';
|
|
3
|
-
import require$$0$1 from 'path';
|
|
3
|
+
import require$$0$1, { join } from 'path';
|
|
4
4
|
import require$$0$2 from 'fs';
|
|
5
5
|
import require$$4$1 from 'process';
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
@@ -22,7 +22,7 @@ import require$$0$4 from 'stream';
|
|
|
22
22
|
import require$$0$5 from 'util';
|
|
23
23
|
import require$$5 from 'assert';
|
|
24
24
|
import { webcrypto } from 'node:crypto';
|
|
25
|
-
import url, {
|
|
25
|
+
import url, { fileURLToPath as fileURLToPath$1 } from 'url';
|
|
26
26
|
import fsPromises from 'node:fs/promises';
|
|
27
27
|
import require$$2 from 'os';
|
|
28
28
|
import require$$3 from 'crypto';
|
|
@@ -30904,7 +30904,7 @@ const getDotenvCliOptions2Options = ({ paths, pathsDelimiter, pathsDelimiterPatt
|
|
|
30904
30904
|
const resolveGetDotenvOptions = async (customOptions) => {
|
|
30905
30905
|
const localPkgDir = await packageDirectory();
|
|
30906
30906
|
const localOptionsPath = localPkgDir
|
|
30907
|
-
?
|
|
30907
|
+
? join(localPkgDir, getDotenvOptionsFilename)
|
|
30908
30908
|
: undefined;
|
|
30909
30909
|
const localOptions = (localOptionsPath && (await fs$a.exists(localOptionsPath))
|
|
30910
30910
|
? JSON.parse((await fs$a.readFile(localOptionsPath)).toString())
|
|
@@ -39226,7 +39226,6 @@ const execShellCommandBatch = async ({ command, globs, ignoreErrors, list, logge
|
|
|
39226
39226
|
logger.info(headerRootPath);
|
|
39227
39227
|
logger.info(headerGlobs);
|
|
39228
39228
|
logger.info(headerCommand);
|
|
39229
|
-
logger.info('');
|
|
39230
39229
|
for (const path of paths) {
|
|
39231
39230
|
// Write path and command to console.
|
|
39232
39231
|
const pathLabel = `CWD: ${path}`;
|
|
@@ -39237,7 +39236,7 @@ const execShellCommandBatch = async ({ command, globs, ignoreErrors, list, logge
|
|
|
39237
39236
|
logger.info('');
|
|
39238
39237
|
logger.info('*'.repeat(pathLabel.length));
|
|
39239
39238
|
logger.info(pathLabel);
|
|
39240
|
-
logger.info(
|
|
39239
|
+
logger.info(headerCommand);
|
|
39241
39240
|
// Execute shell command.
|
|
39242
39241
|
try {
|
|
39243
39242
|
await execaCommand(command, {
|
|
@@ -39353,14 +39352,14 @@ const resolveGetDotenvCliGenerateOptions = async ({ importMetaUrl, ...customOpti
|
|
|
39353
39352
|
})
|
|
39354
39353
|
: undefined;
|
|
39355
39354
|
const globalOptionsPath = globalPkgDir
|
|
39356
|
-
?
|
|
39355
|
+
? join(globalPkgDir, getDotenvOptionsFilename)
|
|
39357
39356
|
: undefined;
|
|
39358
39357
|
const globalOptions = (globalOptionsPath && (await fs$a.exists(globalOptionsPath))
|
|
39359
39358
|
? JSON.parse((await fs$a.readFile(globalOptionsPath)).toString())
|
|
39360
39359
|
: {});
|
|
39361
39360
|
const localPkgDir = await packageDirectory();
|
|
39362
39361
|
const localOptionsPath = localPkgDir
|
|
39363
|
-
?
|
|
39362
|
+
? join(localPkgDir, getDotenvOptionsFilename)
|
|
39364
39363
|
: undefined;
|
|
39365
39364
|
const localOptions = (localOptionsPath &&
|
|
39366
39365
|
localOptionsPath !== globalOptionsPath &&
|
|
@@ -39503,4 +39502,4 @@ const generateGetDotenvCli = async (customOptions) => {
|
|
|
39503
39502
|
});
|
|
39504
39503
|
};
|
|
39505
39504
|
|
|
39506
|
-
export { dotenvExpand, dotenvExpandAll, dotenvExpandFromProcessEnv, generateGetDotenvCli, getDotenv };
|
|
39505
|
+
export { dotenvExpand, dotenvExpandAll, dotenvExpandFromProcessEnv, generateGetDotenvCli, getDotenv, getDotenvCliOptions2Options };
|
package/package.json
CHANGED