mirror of
https://github.com/github/codeql-action.git
synced 2026-01-04 21:50:17 +08:00
Add getOptionalEnvVar function
Also add tests for it and `getRequiredEnvParam`
This commit is contained in:
11
src/util.ts
11
src/util.ts
@@ -673,6 +673,17 @@ export function getRequiredEnvParam(paramName: string): string {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an environment variable, but return `undefined` if it is not set or empty.
|
||||
*/
|
||||
export function getOptionalEnvVar(paramName: string): string | undefined {
|
||||
const value = process.env[paramName];
|
||||
if (value?.trim().length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
export class HTTPError extends Error {
|
||||
public status: number;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user