@driveflux/env 1.3.0 → 1.4.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/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -15
- package/package.json +8 -8
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,OAAO,SAAU,MAAM,iCAYnC,CAAA;AAED,eAAO,MAAM,UAAU,qDAoBtB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import dotenv from 'dotenv';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
for(var k in newEnv){
|
|
13
|
-
if (overwriteEnv || typeof process.env[k] === 'undefined') {
|
|
14
|
-
process.env[k] = newEnv[k];
|
|
4
|
+
export const loadEnv = (path, overwriteEnv = true)=>{
|
|
5
|
+
try {
|
|
6
|
+
console.log('Loading env file: ', path);
|
|
7
|
+
const newEnv = dotenv.parse(fs.readFileSync(path));
|
|
8
|
+
for(const k in newEnv){
|
|
9
|
+
if (overwriteEnv || typeof process.env[k] === 'undefined') {
|
|
10
|
+
process.env[k] = newEnv[k];
|
|
11
|
+
}
|
|
15
12
|
}
|
|
13
|
+
} catch (e) {
|
|
14
|
+
console.log(`Skipping env file "${path}", not found`);
|
|
16
15
|
}
|
|
17
16
|
};
|
|
18
|
-
export
|
|
19
|
-
var basePath = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : process.cwd(), overwriteEnv = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
|
|
17
|
+
export const loadAllEnv = (basePath = process.cwd(), overwriteEnv = true)=>{
|
|
20
18
|
// Load standard env files
|
|
21
19
|
loadEnv(path.join(basePath, '.env'), overwriteEnv);
|
|
22
20
|
loadEnv(path.join(basePath, '.env.local'), overwriteEnv);
|
|
21
|
+
// Default USE_ENV is development
|
|
22
|
+
if (!process.env.USE_ENV && (process.env.NODE_ENV === 'development' || !process.env.NODE_ENV)) {
|
|
23
|
+
process.env.USE_ENV = 'development';
|
|
24
|
+
}
|
|
23
25
|
if (process.env.USE_ENV) {
|
|
24
|
-
loadEnv(path.join(basePath,
|
|
25
|
-
loadEnv(path.join(basePath,
|
|
26
|
+
loadEnv(path.join(basePath, `.env.${process.env.USE_ENV}`), overwriteEnv);
|
|
27
|
+
loadEnv(path.join(basePath, `.env.${process.env.USE_ENV}.local`), overwriteEnv);
|
|
26
28
|
}
|
|
27
29
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@driveflux/env",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -15,14 +15,14 @@
|
|
|
15
15
|
"dotenv": "^16.4.5"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@driveflux/fab": "2.3.
|
|
18
|
+
"@driveflux/fab": "2.3.3",
|
|
19
19
|
"@driveflux/tsconfig": "1.3.0",
|
|
20
|
-
"@swc/cli": "
|
|
21
|
-
"@swc/core": "1.7.
|
|
22
|
-
"@types/lodash": "^4.17.
|
|
23
|
-
"@types/node": "^
|
|
24
|
-
"del-cli": "^
|
|
25
|
-
"typescript": "^5.
|
|
20
|
+
"@swc/cli": "0.4.1-nightly.20240914",
|
|
21
|
+
"@swc/core": "1.7.39",
|
|
22
|
+
"@types/lodash": "^4.17.12",
|
|
23
|
+
"@types/node": "^22.7.8",
|
|
24
|
+
"del-cli": "^6.0.0",
|
|
25
|
+
"typescript": "^5.6.3"
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"build": "fab",
|