@f5-sales-demo/pi-utils 21.12.2 → 21.13.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/package.json +2 -2
- package/src/env.ts +23 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@f5-sales-demo/pi-utils",
|
|
4
|
-
"version": "21.
|
|
4
|
+
"version": "21.13.1",
|
|
5
5
|
"description": "Shared utilities for pi packages",
|
|
6
6
|
"homepage": "https://github.com/f5-sales-demo/xcsh",
|
|
7
7
|
"author": "Can Boluk",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/bun": "^1.3",
|
|
42
|
-
"@f5-sales-demo/pi-natives": "21.
|
|
42
|
+
"@f5-sales-demo/pi-natives": "21.13.1"
|
|
43
43
|
},
|
|
44
44
|
"engines": {
|
|
45
45
|
"bun": ">=1.3.7"
|
package/src/env.ts
CHANGED
|
@@ -83,6 +83,29 @@ export function $pickenv(...keys: string[]): string | undefined {
|
|
|
83
83
|
return undefined;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
/**
|
|
87
|
+
* Read an environment variable by its exact, case-sensitive name.
|
|
88
|
+
*
|
|
89
|
+
* Windows exposes case-insensitive getters for `process.env`, but enumerating
|
|
90
|
+
* keys preserves their real casing. Only trust a lookup when the requested
|
|
91
|
+
* spelling is present in that enumeration. This prevents a literal config
|
|
92
|
+
* value such as `public` from resolving to Windows' built-in `PUBLIC` path.
|
|
93
|
+
*
|
|
94
|
+
* @param name Environment variable name to look up.
|
|
95
|
+
* @param env Environment source; defaults to `process.env`.
|
|
96
|
+
*/
|
|
97
|
+
export function $envExact(
|
|
98
|
+
name: string,
|
|
99
|
+
env: Readonly<Record<string, string | undefined>> = process.env,
|
|
100
|
+
): string | undefined {
|
|
101
|
+
const value = env[name];
|
|
102
|
+
if (value === undefined) return undefined;
|
|
103
|
+
for (const key in env) {
|
|
104
|
+
if (key === name) return value;
|
|
105
|
+
}
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
|
|
86
109
|
/**
|
|
87
110
|
* Parses a positive decimal integer from `$env[name]`.
|
|
88
111
|
* Empty, invalid, NaN, zero, or negative values return `defaultValue`.
|