@karmaniverous/get-dotenv 4.4.4 → 4.5.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 CHANGED
@@ -84,14 +84,17 @@ Since keys will be evaluated progressively, each successive key function will ha
84
84
 
85
85
  Even though the rest of your project is in TypeScript, the dynamic processing module SHOULD be in JavasScript.
86
86
 
87
- 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.
87
+ Think about it: the module is loaded via a dynamic import, with the file name determined at run time. If you write this module in TS, you'll 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 to do for some very simple logic.
88
88
 
89
89
  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:
90
90
 
91
91
  ```ts
92
92
  export type ProcessEnv = Record<string, string | undefined>;
93
93
 
94
- export type GetDotenvDynamicFunction = (vars: ProcessEnv) => string | undefined;
94
+ export type GetDotenvDynamicFunction = (
95
+ vars: ProcessEnv,
96
+ env: string | undefined,
97
+ ) => string | undefined;
95
98
 
96
99
  export type GetDotenvDynamic = Record<
97
100
  string,
@@ -99,6 +102,8 @@ export type GetDotenvDynamic = Record<
99
102
  >;
100
103
  ```
101
104
 
105
+ The second argumnt `env` of the `GetDotenvDynamicFunction` type is the environment token (if any) specified in the controlling `getDotenv` call.
106
+
102
107
  ## Command Line Interface
103
108
 
104
109
  You can also use `getdotenv` from the command line:
@@ -32886,7 +32886,7 @@ const getDotenv = async (options = {}) => {
32886
32886
  for (const key in dynamic)
32887
32887
  Object.assign(dotenv, {
32888
32888
  [key]: _.isFunction(dynamic[key])
32889
- ? dynamic[key](dotenv)
32889
+ ? dynamic[key](dotenv, env ?? defaultEnv)
32890
32890
  : dynamic[key],
32891
32891
  });
32892
32892
  }
package/dist/index.cjs CHANGED
@@ -32887,7 +32887,7 @@ const getDotenv = async (options = {}) => {
32887
32887
  for (const key in dynamic)
32888
32888
  Object.assign(dotenv, {
32889
32889
  [key]: _.isFunction(dynamic[key])
32890
- ? dynamic[key](dotenv)
32890
+ ? dynamic[key](dotenv, env ?? defaultEnv)
32891
32891
  : dynamic[key],
32892
32892
  });
32893
32893
  }
package/dist/index.d.cts CHANGED
@@ -66,7 +66,7 @@ interface GetDotenvCliOptions extends Omit<GetDotenvOptions, 'paths' | 'vars'> {
66
66
  }
67
67
 
68
68
  type ProcessEnv = Record<string, string | undefined>;
69
- type GetDotenvDynamicFunction = (vars: ProcessEnv) => string | undefined;
69
+ type GetDotenvDynamicFunction = (vars: ProcessEnv, env: string | undefined) => string | undefined;
70
70
  type GetDotenvDynamic = Record<string, GetDotenvDynamicFunction | ReturnType<GetDotenvDynamicFunction>>;
71
71
  type Logger = Record<string, (...args: unknown[]) => void> | typeof console;
72
72
  /**
package/dist/index.d.mts CHANGED
@@ -66,7 +66,7 @@ interface GetDotenvCliOptions extends Omit<GetDotenvOptions, 'paths' | 'vars'> {
66
66
  }
67
67
 
68
68
  type ProcessEnv = Record<string, string | undefined>;
69
- type GetDotenvDynamicFunction = (vars: ProcessEnv) => string | undefined;
69
+ type GetDotenvDynamicFunction = (vars: ProcessEnv, env: string | undefined) => string | undefined;
70
70
  type GetDotenvDynamic = Record<string, GetDotenvDynamicFunction | ReturnType<GetDotenvDynamicFunction>>;
71
71
  type Logger = Record<string, (...args: unknown[]) => void> | typeof console;
72
72
  /**
package/dist/index.d.ts CHANGED
@@ -66,7 +66,7 @@ interface GetDotenvCliOptions extends Omit<GetDotenvOptions, 'paths' | 'vars'> {
66
66
  }
67
67
 
68
68
  type ProcessEnv = Record<string, string | undefined>;
69
- type GetDotenvDynamicFunction = (vars: ProcessEnv) => string | undefined;
69
+ type GetDotenvDynamicFunction = (vars: ProcessEnv, env: string | undefined) => string | undefined;
70
70
  type GetDotenvDynamic = Record<string, GetDotenvDynamicFunction | ReturnType<GetDotenvDynamicFunction>>;
71
71
  type Logger = Record<string, (...args: unknown[]) => void> | typeof console;
72
72
  /**
package/dist/index.mjs CHANGED
@@ -32885,7 +32885,7 @@ const getDotenv = async (options = {}) => {
32885
32885
  for (const key in dynamic)
32886
32886
  Object.assign(dotenv, {
32887
32887
  [key]: _.isFunction(dynamic[key])
32888
- ? dynamic[key](dotenv)
32888
+ ? dynamic[key](dotenv, env ?? defaultEnv)
32889
32889
  : dynamic[key],
32890
32890
  });
32891
32891
  }
package/package.json CHANGED
@@ -129,12 +129,11 @@
129
129
  "knip": "knip",
130
130
  "lint": "eslint src/** && prettier -c src",
131
131
  "lint:fix": "eslint --fix src/** && prettier --write src",
132
- "postinstall": "npm audit fix",
133
132
  "release": "release-it",
134
133
  "release:pre": "vc -c \"release-it --no-git.requireBranch --github.prerelease --preRelease\"",
135
134
  "test": "cross-env LOG_LEVEL=debug nyc mocha"
136
135
  },
137
136
  "type": "module",
138
137
  "types": "dist/index.d.ts",
139
- "version": "4.4.4"
138
+ "version": "4.5.0"
140
139
  }