@driveflux/env 1.2.3-next.0 → 1.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/dist/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
- export declare const loadEnv: (path: string, overwriteEnv?: boolean) => void;
2
1
  export declare const loadAllEnv: (basePath?: string, overwriteEnv?: boolean) => void;
3
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
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,qDAWtB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAkBA,eAAO,MAAM,UAAU,qDAWtB,CAAA"}
package/dist/index.js CHANGED
@@ -1,25 +1,27 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import dotenv from 'dotenv';
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
- }
4
+ var loadEnv = function(path) {
5
+ var overwriteEnv = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
6
+ console.log('Loading env file: ', path);
7
+ if (!fs.existsSync(path)) {
8
+ console.log('Skipping env file "'.concat(path, '", not found'));
9
+ return;
10
+ }
11
+ var newEnv = dotenv.parse(fs.readFileSync(path));
12
+ for(var k in newEnv){
13
+ if (overwriteEnv || typeof process.env[k] === 'undefined') {
14
+ process.env[k] = newEnv[k];
12
15
  }
13
- } catch (e) {
14
- console.log(`Skipping env file "${path}", not found`);
15
16
  }
16
17
  };
17
- export const loadAllEnv = (basePath = process.cwd(), overwriteEnv = true)=>{
18
+ export var loadAllEnv = function() {
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;
18
20
  // Load standard env files
19
21
  loadEnv(path.join(basePath, '.env'), overwriteEnv);
20
22
  loadEnv(path.join(basePath, '.env.local'), overwriteEnv);
21
23
  if (process.env.USE_ENV) {
22
- loadEnv(path.join(basePath, `.env.${process.env.USE_ENV}`), overwriteEnv);
23
- loadEnv(path.join(basePath, `.env.${process.env.USE_ENV}.local`), overwriteEnv);
24
+ loadEnv(path.join(basePath, ".env.".concat(process.env.USE_ENV)), overwriteEnv);
25
+ loadEnv(path.join(basePath, ".env.".concat(process.env.USE_ENV, ".local")), overwriteEnv);
24
26
  }
25
27
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@driveflux/env",
3
- "version": "1.2.3-next.0",
3
+ "version": "1.3.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.2.2-next.0",
19
- "@driveflux/tsconfig": "1.2.2-next.0",
20
- "@swc/cli": "0.4.1-nightly.20240914",
21
- "@swc/core": "1.7.36",
22
- "@types/lodash": "^4.17.12",
23
- "@types/node": "^22.7.7",
24
- "del-cli": "^6.0.0",
25
- "typescript": "^5.6.3"
18
+ "@driveflux/fab": "2.3.0",
19
+ "@driveflux/tsconfig": "1.3.0",
20
+ "@swc/cli": "^0.4.0",
21
+ "@swc/core": "1.7.2",
22
+ "@types/lodash": "^4.17.7",
23
+ "@types/node": "^20.14.12",
24
+ "del-cli": "^5.1.0",
25
+ "typescript": "^5.5.4"
26
26
  },
27
27
  "scripts": {
28
28
  "build": "fab",