feat(core): Added new method getEnvVarOnDemandStrict to throw error for unset env vars
This commit is contained in:
parent
5b1e3a184b
commit
e25406662f
@ -1,5 +1,11 @@
|
||||
# Changelog
|
||||
|
||||
## 2024-11-22 - 6.1.0 - feat(core)
|
||||
Added new method getEnvVarOnDemandStrict to throw error for unset env vars
|
||||
|
||||
- Introduced getEnvVarOnDemandStrict method in Qenv class for strict retrieval of environment variables.
|
||||
- Upgraded various @git.zone and @push.rocks dependencies for improved functionality and security.
|
||||
|
||||
## 2024-11-18 - 6.0.8 - fix(Qenv)
|
||||
Fix environment file path initialization logic.
|
||||
|
||||
|
18
package.json
18
package.json
@ -31,18 +31,18 @@
|
||||
},
|
||||
"homepage": "https://code.foss.global/push.rocks/qenv",
|
||||
"devDependencies": {
|
||||
"@git.zone/tsbuild": "^2.1.72",
|
||||
"@git.zone/tsrun": "^1.2.44",
|
||||
"@git.zone/tstest": "^1.0.86",
|
||||
"@push.rocks/tapbundle": "^5.0.15",
|
||||
"@types/node": "^20.11.17"
|
||||
"@git.zone/tsbuild": "^2.2.0",
|
||||
"@git.zone/tsrun": "^1.3.3",
|
||||
"@git.zone/tstest": "^1.0.90",
|
||||
"@push.rocks/tapbundle": "^5.5.0",
|
||||
"@types/node": "^22.9.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@api.global/typedrequest": "^3.0.4",
|
||||
"@api.global/typedrequest": "^3.1.10",
|
||||
"@configvault.io/interfaces": "^1.0.17",
|
||||
"@push.rocks/smartfile": "^11.0.4",
|
||||
"@push.rocks/smartlog": "^3.0.3",
|
||||
"@push.rocks/smartpath": "^5.0.11"
|
||||
"@push.rocks/smartfile": "^11.0.21",
|
||||
"@push.rocks/smartlog": "^3.0.7",
|
||||
"@push.rocks/smartpath": "^5.0.18"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
|
11656
pnpm-lock.yaml
generated
11656
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/qenv',
|
||||
version: '6.0.8',
|
||||
version: '6.1.0',
|
||||
description: 'A module for easily handling environment variables in Node.js projects with support for .yml and .json configuration.'
|
||||
}
|
||||
|
@ -111,6 +111,21 @@ export class Qenv {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Like getEnvVarOnDemand, but throws an error if the env var is not set.
|
||||
* @param envVarNameOrNames
|
||||
* @returns
|
||||
*/
|
||||
public async getEnvVarOnDemandStrict(
|
||||
envVarNameOrNames: TEnvVarRef | TEnvVarRef[]
|
||||
): Promise<string> {
|
||||
const value = await this.getEnvVarOnDemand(envVarNameOrNames);
|
||||
if (!value) {
|
||||
throw new Error(`Env var ${envVarNameOrNames} is not set!`);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public getEnvVarOnDemandSync(envVarNameOrNames: string | string[]): string | undefined {
|
||||
console.warn('requesting env var sync leaves out potentially important async env sources.');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user