@karmaniverous/get-dotenv 2.0.0 → 2.0.1

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.
@@ -82,9 +82,15 @@ const getDotenv = async function () {
82
82
  if (dynamicPath && !excludeDynamic) {
83
83
  const dynamic = new Function(`return ${(await _fsExtra.default.readFile(dynamicPath)).toString()}`)()(dotenv);
84
84
  Object.keys(dynamic).forEach(key => {
85
- Object.assign(dotenv, {
86
- [key]: dynamic[key](dotenv)
87
- });
85
+ try {
86
+ Object.assign(dotenv, {
87
+ [key]: dynamic[key](dotenv)
88
+ });
89
+ } catch ({
90
+ message
91
+ }) {
92
+ throw new Error(`Dynamic processing failed for variable '${key}' with message '${message}'`);
93
+ }
88
94
  });
89
95
  }
90
96
 
@@ -94,7 +94,13 @@ export const getDotenv = async ({
94
94
  `return ${(await fs.readFile(dynamicPath)).toString()}`
95
95
  )()(dotenv);
96
96
  Object.keys(dynamic).forEach((key) => {
97
- Object.assign(dotenv, { [key]: dynamic[key](dotenv) });
97
+ try {
98
+ Object.assign(dotenv, { [key]: dynamic[key](dotenv) });
99
+ } catch ({ message }) {
100
+ throw new Error(
101
+ `Dynamic processing failed for variable '${key}' with message '${message}'`
102
+ );
103
+ }
98
104
  });
99
105
  }
100
106
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "bin": {
4
4
  "getdotenv": "bin/getdotenv/index.js"
5
5
  },
6
- "version": "2.0.0",
6
+ "version": "2.0.1",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },