@alwatr/env 6.0.0 → 6.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.
package/dist/main.js CHANGED
@@ -1,5 +1,5 @@
1
- /* 📦 @alwatr/env v6.0.0 */
1
+ /* 📦 @alwatr/env v6.0.1 */
2
2
  import{platformInfo as k}from"@alwatr/platform-info";function x(j){let h=process.env[j.name];if(h==="")h=void 0;if(k.development===!0)h??=j.developmentValue??j.defaultValue;else h??=j.defaultValue;if(h===void 0)throw Error(`Environment variable "${j.name}" is required.`);return h}export{x as getEnv};
3
3
 
4
- //# debugId=9C51324E9F77C0E464756E2164756E21
4
+ //# debugId=6DE50F270AB4F9B164756E2164756E21
5
5
  //# sourceMappingURL=main.js.map
package/dist/main.js.map CHANGED
@@ -5,6 +5,6 @@
5
5
  "import {platformInfo} from '@alwatr/platform-info';\n\n/**\n * Parameters for retrieving an environment variable value.\n */\nexport type GetEnvOption = {\n /**\n * The name of the environment variable.\n */\n name: string;\n\n /**\n * The default value to use if the environment variable is not set.\n * If not provided, the environment variable is required and an error will be thrown if it is not set.\n * Except in development mode, where the development value will be used instead if provided.\n */\n defaultValue?: string;\n\n /**\n * The value to use in a development environment.\n * It will be overwrite the default value in development mode and completely ignored in production mode.\n */\n developmentValue?: string;\n};\n\nexport function getEnv(option: GetEnvOption): string {\n let value = process.env[option.name];\n if (value === '') value = undefined; // empty string is considered as undefined in environment variables\n\n if (platformInfo.development === true) {\n value ??= option.developmentValue ?? option.defaultValue;\n }\n else {\n value ??= option.defaultValue;\n }\n\n if (value === undefined) {\n throw new Error(`Environment variable \"${option.name}\" is required.`);\n }\n\n return value;\n}\n"
6
6
  ],
7
7
  "mappings": ";AAAA,uBAAQ,8BAyBD,SAAS,CAAM,CAAC,EAA8B,CACnD,IAAI,EAAQ,QAAQ,IAAI,EAAO,MAC/B,GAAI,IAAU,GAAI,EAAQ,OAE1B,GAAI,EAAa,cAAgB,GAC/B,IAAU,EAAO,kBAAoB,EAAO,aAG5C,SAAU,EAAO,aAGnB,GAAI,IAAU,OACZ,MAAU,MAAM,yBAAyB,EAAO,oBAAoB,EAGtE,OAAO",
8
- "debugId": "9C51324E9F77C0E464756E2164756E21",
8
+ "debugId": "6DE50F270AB4F9B164756E2164756E21",
9
9
  "names": []
10
10
  }
package/package.json CHANGED
@@ -1,25 +1,50 @@
1
1
  {
2
2
  "name": "@alwatr/env",
3
+ "version": "6.0.1",
3
4
  "description": "A tiny and tree-shakable TypeScript library to get environment variables with type-safe and fallback value for development and production.",
4
- "version": "6.0.0",
5
+ "license": "MPL-2.0",
5
6
  "author": "S. Ali Mihandoost <ali.mihandoost@gmail.com>",
7
+ "type": "module",
8
+ "repository": {
9
+ "directory": "packages/env",
10
+ "type": "git",
11
+ "url": "https://github.com/Alwatr/nanolib"
12
+ },
13
+ "homepage": "https://github.com/Alwatr/nanolib/tree/next/packages/env#readme",
6
14
  "bugs": "https://github.com/Alwatr/nanolib/issues",
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/main.d.ts",
18
+ "default": "./dist/main.js"
19
+ }
20
+ },
21
+ "sideEffects": false,
7
22
  "dependencies": {
8
- "@alwatr/platform-info": "6.0.0"
23
+ "@alwatr/platform-info": "6.0.1"
9
24
  },
10
25
  "devDependencies": {
11
- "@alwatr/nano-build": "7.0.0",
12
- "@alwatr/prettier-config": "7.0.0",
13
- "@alwatr/tsconfig-base": "7.0.0",
14
- "@alwatr/type-helper": "8.0.0",
26
+ "@alwatr/nano-build": "7.0.1",
27
+ "@alwatr/prettier-config": "7.0.1",
28
+ "@alwatr/tsconfig-base": "8.0.0",
29
+ "@alwatr/type-helper": "8.0.1",
15
30
  "@types/node": "^24.12.0",
16
31
  "typescript": "^5.9.3"
17
32
  },
18
- "exports": {
19
- ".": {
20
- "types": "./dist/main.d.ts",
21
- "default": "./dist/main.js"
22
- }
33
+ "scripts": {
34
+ "b": "bun run build",
35
+ "build": "bun run build:ts && bun run build:es",
36
+ "build:es": "nano-build --preset=module src/main.ts",
37
+ "build:ts": "tsc --build",
38
+ "c": "bun run clean",
39
+ "cb": "bun run clean && bun run build",
40
+ "clean": "rm -rfv dist *.tsbuildinfo",
41
+ "d": "bun run build:es && bun",
42
+ "t": "bun run test",
43
+ "test": "bun test",
44
+ "w": "bun run watch",
45
+ "watch": "bun run watch:ts & bun run watch:es",
46
+ "watch:es": "bun run build:es --watch",
47
+ "watch:ts": "bun run build:ts --watch --preserveWatchOutput"
23
48
  },
24
49
  "files": [
25
50
  "**/*.{js,mjs,cjs,ts,map,d.ts,html,LEGAL.txt}",
@@ -28,7 +53,9 @@
28
53
  "!demo/**/*",
29
54
  "!**/*.test.js"
30
55
  ],
31
- "homepage": "https://github.com/Alwatr/nanolib/tree/next/packages/env#readme",
56
+ "publishConfig": {
57
+ "access": "public"
58
+ },
32
59
  "keywords": [
33
60
  "alwatr",
34
61
  "browser",
@@ -46,34 +73,6 @@
46
73
  "utility",
47
74
  "utils"
48
75
  ],
49
- "license": "MPL-2.0",
50
76
  "prettier": "@alwatr/prettier-config",
51
- "publishConfig": {
52
- "access": "public"
53
- },
54
- "repository": {
55
- "type": "git",
56
- "url": "https://github.com/Alwatr/nanolib",
57
- "directory": "packages/env"
58
- },
59
- "scripts": {
60
- "b": "bun run build",
61
- "build": "bun run build:ts && bun run build:es",
62
- "build:es": "nano-build --preset=module src/main.ts",
63
- "build:ts": "tsc --build",
64
- "c": "bun run clean",
65
- "cb": "bun run clean && bun run build",
66
- "clean": "rm -rfv dist *.tsbuildinfo",
67
- "d": "bun run build:es && bun",
68
- "t": "bun run test",
69
- "test": "bun test",
70
- "w": "bun run watch",
71
- "watch": "bun run watch:ts & bun run watch:es",
72
- "watch:es": "bun run build:es --watch",
73
- "watch:ts": "bun run build:ts --watch --preserveWatchOutput"
74
- },
75
- "sideEffects": false,
76
- "type": "module",
77
- "types": "./dist/main.d.ts",
78
- "gitHead": "056102a1c8a563bbae8a290b6830450f467322a3"
77
+ "gitHead": "f843742e94d6ebed3921d57b624d9deb35c2c102"
79
78
  }