diff --git a/lib/analyze-action.js b/lib/analyze-action.js index cdbdadfc7..8efd202ad 100644 --- a/lib/analyze-action.js +++ b/lib/analyze-action.js @@ -89751,6 +89751,13 @@ function getRequiredEnvParam(paramName) { } return value; } +function getOptionalEnvVar(paramName) { + const value = process.env[paramName]; + if (value?.trim().length === 0) { + return void 0; + } + return value; +} var HTTPError = class extends Error { constructor(message, status) { super(message); @@ -95935,8 +95942,8 @@ async function postProcessSarifFiles(logger, features, checkoutPath, sarifPaths, return { sarif, analysisKey, environment }; } async function writePostProcessedFiles(logger, pathInput, uploadTarget, postProcessingResults) { - const outputPath = pathInput || process.env["CODEQL_ACTION_SARIF_DUMP_DIR" /* SARIF_DUMP_DIR */]; - if (outputPath !== void 0 && outputPath.trim() !== "") { + const outputPath = pathInput || getOptionalEnvVar("CODEQL_ACTION_SARIF_DUMP_DIR" /* SARIF_DUMP_DIR */); + if (outputPath !== void 0) { dumpSarifFile( JSON.stringify(postProcessingResults.sarif), outputPath, diff --git a/lib/upload-lib.js b/lib/upload-lib.js index b15a45060..15b698956 100644 --- a/lib/upload-lib.js +++ b/lib/upload-lib.js @@ -88330,6 +88330,13 @@ function getRequiredEnvParam(paramName) { } return value; } +function getOptionalEnvVar(paramName) { + const value = process.env[paramName]; + if (value?.trim().length === 0) { + return void 0; + } + return value; +} var HTTPError = class extends Error { constructor(message, status) { super(message); @@ -92749,8 +92756,8 @@ async function postProcessSarifFiles(logger, features, checkoutPath, sarifPaths, return { sarif, analysisKey, environment }; } async function writePostProcessedFiles(logger, pathInput, uploadTarget, postProcessingResults) { - const outputPath = pathInput || process.env["CODEQL_ACTION_SARIF_DUMP_DIR" /* SARIF_DUMP_DIR */]; - if (outputPath !== void 0 && outputPath.trim() !== "") { + const outputPath = pathInput || getOptionalEnvVar("CODEQL_ACTION_SARIF_DUMP_DIR" /* SARIF_DUMP_DIR */); + if (outputPath !== void 0) { dumpSarifFile( JSON.stringify(postProcessingResults.sarif), outputPath, diff --git a/lib/upload-sarif-action.js b/lib/upload-sarif-action.js index 4ca9ea980..8f73900e1 100644 --- a/lib/upload-sarif-action.js +++ b/lib/upload-sarif-action.js @@ -88444,6 +88444,13 @@ function getRequiredEnvParam(paramName) { } return value; } +function getOptionalEnvVar(paramName) { + const value = process.env[paramName]; + if (value?.trim().length === 0) { + return void 0; + } + return value; +} var HTTPError = class extends Error { constructor(message, status) { super(message); @@ -93405,8 +93412,8 @@ async function postProcessSarifFiles(logger, features, checkoutPath, sarifPaths, return { sarif, analysisKey, environment }; } async function writePostProcessedFiles(logger, pathInput, uploadTarget, postProcessingResults) { - const outputPath = pathInput || process.env["CODEQL_ACTION_SARIF_DUMP_DIR" /* SARIF_DUMP_DIR */]; - if (outputPath !== void 0 && outputPath.trim() !== "") { + const outputPath = pathInput || getOptionalEnvVar("CODEQL_ACTION_SARIF_DUMP_DIR" /* SARIF_DUMP_DIR */); + if (outputPath !== void 0) { dumpSarifFile( JSON.stringify(postProcessingResults.sarif), outputPath, diff --git a/src/upload-lib.ts b/src/upload-lib.ts index 573ca670c..3ec663e0f 100644 --- a/src/upload-lib.ts +++ b/src/upload-lib.ts @@ -774,10 +774,10 @@ export async function writePostProcessedFiles( postProcessingResults: PostProcessingResults, ) { // If there's an explicit input, use that. Otherwise, use the value from the environment variable. - const outputPath = pathInput || process.env[EnvVar.SARIF_DUMP_DIR]; + const outputPath = pathInput || util.getOptionalEnvVar(EnvVar.SARIF_DUMP_DIR); // If we have a non-empty output path, write the SARIF file to it. - if (outputPath !== undefined && outputPath.trim() !== "") { + if (outputPath !== undefined) { dumpSarifFile( JSON.stringify(postProcessingResults.sarif), outputPath,