@alwatr/env 6.0.1 → 9.1.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/main.js +2 -2
- package/dist/main.js.map +1 -1
- package/package.json +22 -23
package/dist/main.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* 📦 @alwatr/env
|
|
1
|
+
/* 📦 @alwatr/env v9.1.0 */
|
|
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=
|
|
4
|
+
//# debugId=8D07AFB96A7AE21E64756E2164756E21
|
|
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": "
|
|
8
|
+
"debugId": "8D07AFB96A7AE21E64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
package/package.json
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alwatr/env",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.1.0",
|
|
4
4
|
"description": "A tiny and tree-shakable TypeScript library to get environment variables with type-safe and fallback value for development and production.",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
|
-
"author": "S. Ali Mihandoost <ali.mihandoost@gmail.com>",
|
|
6
|
+
"author": "S. Ali Mihandoost <ali.mihandoost@gmail.com> (https://ali.mihandoost.com)",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"repository": {
|
|
9
|
-
"directory": "packages/env",
|
|
10
9
|
"type": "git",
|
|
11
|
-
"url": "https://github.com/Alwatr/
|
|
10
|
+
"url": "https://github.com/Alwatr/alwatr",
|
|
11
|
+
"directory": "pkg/nanolib/env"
|
|
12
12
|
},
|
|
13
|
-
"homepage": "https://github.com/Alwatr/
|
|
14
|
-
"bugs": "https://github.com/Alwatr/
|
|
13
|
+
"homepage": "https://github.com/Alwatr/alwatr/tree/main/pkg/nanolib/env#readme",
|
|
14
|
+
"bugs": "https://github.com/Alwatr/alwatr/issues",
|
|
15
15
|
"exports": {
|
|
16
16
|
".": {
|
|
17
17
|
"types": "./dist/main.d.ts",
|
|
18
|
+
"import": "./dist/main.js",
|
|
18
19
|
"default": "./dist/main.js"
|
|
19
20
|
}
|
|
20
21
|
},
|
|
21
22
|
"sideEffects": false,
|
|
22
23
|
"dependencies": {
|
|
23
|
-
"@alwatr/platform-info": "
|
|
24
|
+
"@alwatr/platform-info": "9.1.0"
|
|
24
25
|
},
|
|
25
26
|
"devDependencies": {
|
|
26
|
-
"@alwatr/nano-build": "
|
|
27
|
-
"@alwatr/
|
|
28
|
-
"@alwatr/
|
|
29
|
-
"@
|
|
30
|
-
"
|
|
31
|
-
"typescript": "^5.9.3"
|
|
27
|
+
"@alwatr/nano-build": "9.1.0",
|
|
28
|
+
"@alwatr/tsconfig-base": "9.1.0",
|
|
29
|
+
"@alwatr/type-helper": "9.1.0",
|
|
30
|
+
"@types/node": "^25.5.0",
|
|
31
|
+
"typescript": "^6.0.2"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"b": "bun run build",
|
|
35
35
|
"build": "bun run build:ts && bun run build:es",
|
|
36
36
|
"build:es": "nano-build --preset=module src/main.ts",
|
|
37
37
|
"build:ts": "tsc --build",
|
|
38
|
-
"
|
|
39
|
-
"cb": "bun run clean && bun run build",
|
|
38
|
+
"cl": "bun run clean",
|
|
40
39
|
"clean": "rm -rfv dist *.tsbuildinfo",
|
|
41
|
-
"
|
|
40
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
41
|
+
"lint": "eslint src/ --ext .ts",
|
|
42
42
|
"t": "bun run test",
|
|
43
|
-
"test": "bun test",
|
|
43
|
+
"test": "ALWATR_DEBUG=0 bun test",
|
|
44
44
|
"w": "bun run watch",
|
|
45
45
|
"watch": "bun run watch:ts & bun run watch:es",
|
|
46
46
|
"watch:es": "bun run build:es --watch",
|
|
47
47
|
"watch:ts": "bun run build:ts --watch --preserveWatchOutput"
|
|
48
48
|
},
|
|
49
49
|
"files": [
|
|
50
|
-
"
|
|
50
|
+
"dist",
|
|
51
|
+
"src/**/*.ts",
|
|
52
|
+
"!src/**/*.test.ts",
|
|
51
53
|
"README.md",
|
|
52
|
-
"LICENSE"
|
|
53
|
-
"!demo/**/*",
|
|
54
|
-
"!**/*.test.js"
|
|
54
|
+
"LICENSE"
|
|
55
55
|
],
|
|
56
56
|
"publishConfig": {
|
|
57
57
|
"access": "public"
|
|
@@ -73,6 +73,5 @@
|
|
|
73
73
|
"utility",
|
|
74
74
|
"utils"
|
|
75
75
|
],
|
|
76
|
-
"
|
|
77
|
-
"gitHead": "f843742e94d6ebed3921d57b624d9deb35c2c102"
|
|
76
|
+
"gitHead": "4a25cd3e0499cf61dd761e87d3711abf9b0cd208"
|
|
78
77
|
}
|