| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Also add tests for it and `getRequiredEnvParam`
| */ | ||
| export function getOptionalEnvVar(paramName: string): string | undefined { | ||
| const value = process.env[paramName]; | ||
| if (value?.trim().length === 0) { |
There was a problem hiding this comment.
Minor: this trims but getRequiredEnvParam doesn't — should we be consistent?
Sorry, something went wrong.
There was a problem hiding this comment.
Let's be inconsistent for now. Mainly because this would be a stricter requirement for getOptionalEnvVar than what we currently have and getOptionalEnvVar is only used in one (new) place for now where we don't risk breaking anything.
Sorry, something went wrong.
There was a problem hiding this comment.
This PR introduces a new getOptionalEnvVar helper function to safely retrieve environment variables that may not be set or may be empty, returning undefined in those cases. This complements the existing getRequiredEnvParam function and is immediately applied to simplify the logic in writePostProcessedFiles.
Key changes:
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file| File | Description |
|---|---|
| src/util.ts | Added getOptionalEnvVar helper function |
| src/util.test.ts | Added comprehensive test coverage for both getRequiredEnvParam and getOptionalEnvVar |
| src/upload-lib.ts | Applied getOptionalEnvVar to simplify environment variable retrieval logic |
| lib/upload-sarif-action.js | Generated JavaScript from TypeScript changes |
| lib/upload-lib.js | Generated JavaScript from TypeScript changes |
| lib/analyze-action.js | Generated JavaScript from TypeScript changes |
lib/upload-sarif-action.js:1
"use strict";
lib/upload-lib.js:1
"use strict";
lib/analyze-action.js:1
"use strict";
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
We have a helper function for inputs which gets the corresponding value, if it is set and not empty. We don't have this for environment variables. This PR adds getOptionalEnvVar to address that.
Risk assessment
For internal use only. Please select the risk level of this change:
Which use cases does this change impact?
How did/will you validate this change?
If something goes wrong after this change is released, what are the mitigation and rollback strategies?
How will you know if something goes wrong after this change is released?
Merge / deployment checklist