@karmaniverous/get-dotenv 4.2.4 → 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/index.cjs +1 -0
- 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 +1 -1
- 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/index.cjs
CHANGED
|
@@ -39509,3 +39509,4 @@ exports.dotenvExpandAll = dotenvExpandAll;
|
|
|
39509
39509
|
exports.dotenvExpandFromProcessEnv = dotenvExpandFromProcessEnv;
|
|
39510
39510
|
exports.generateGetDotenvCli = generateGetDotenvCli;
|
|
39511
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
|
@@ -39502,4 +39502,4 @@ const generateGetDotenvCli = async (customOptions) => {
|
|
|
39502
39502
|
});
|
|
39503
39503
|
};
|
|
39504
39504
|
|
|
39505
|
-
export { dotenvExpand, dotenvExpandAll, dotenvExpandFromProcessEnv, generateGetDotenvCli, getDotenv };
|
|
39505
|
+
export { dotenvExpand, dotenvExpandAll, dotenvExpandFromProcessEnv, generateGetDotenvCli, getDotenv, getDotenvCliOptions2Options };
|
package/package.json
CHANGED