Move error checks out of getSarifFilePaths

This commit is contained in:
Michael B. Gale
2025-09-26 14:41:58 +01:00
parent 65925679a3
commit 022d7d5aa6
4 changed files with 56 additions and 45 deletions
+13 -11
View File
@@ -95568,18 +95568,10 @@ function findSarifFilesInDir(sarifPath, isSarif) {
walkSarifFiles(sarifPath);
return sarifFiles;
}
function getSarifFilePaths(sarifPath, isSarif) {
if (!fs18.existsSync(sarifPath)) {
throw new ConfigurationError(`Path does not exist: ${sarifPath}`);
}
function getSarifFilePaths(sarifPath, isSarif, pathStats) {
let sarifFiles;
if (fs18.lstatSync(sarifPath).isDirectory()) {
if (pathStats.isDirectory()) {
sarifFiles = findSarifFilesInDir(sarifPath, isSarif);
if (sarifFiles.length === 0) {
throw new ConfigurationError(
`No SARIF files found to upload in "${sarifPath}".`
);
}
} else {
sarifFiles = [sarifPath];
}
@@ -95681,10 +95673,20 @@ function buildPayload(commitOid, ref, analysisKey, analysisName, zippedSarif, wo
return payloadObj;
}
async function uploadFiles(inputSarifPath, checkoutPath, category, features, logger, uploadTarget) {
const pathStats = fs18.lstatSync(inputSarifPath, { throwIfNoEntry: false });
if (pathStats === void 0) {
throw new ConfigurationError(`Path does not exist: ${inputSarifPath}`);
}
const sarifPaths = getSarifFilePaths(
inputSarifPath,
uploadTarget.sarifPredicate
uploadTarget.sarifPredicate,
pathStats
);
if (sarifPaths.length === 0) {
throw new ConfigurationError(
`No SARIF files found to upload in "${inputSarifPath}".`
);
}
return uploadSpecifiedFiles(
sarifPaths,
checkoutPath,
+13 -11
View File
@@ -133002,18 +133002,10 @@ function findSarifFilesInDir(sarifPath, isSarif) {
walkSarifFiles(sarifPath);
return sarifFiles;
}
function getSarifFilePaths(sarifPath, isSarif) {
if (!fs17.existsSync(sarifPath)) {
throw new ConfigurationError(`Path does not exist: ${sarifPath}`);
}
function getSarifFilePaths(sarifPath, isSarif, pathStats) {
let sarifFiles;
if (fs17.lstatSync(sarifPath).isDirectory()) {
if (pathStats.isDirectory()) {
sarifFiles = findSarifFilesInDir(sarifPath, isSarif);
if (sarifFiles.length === 0) {
throw new ConfigurationError(
`No SARIF files found to upload in "${sarifPath}".`
);
}
} else {
sarifFiles = [sarifPath];
}
@@ -133115,10 +133107,20 @@ function buildPayload(commitOid, ref, analysisKey, analysisName, zippedSarif, wo
return payloadObj;
}
async function uploadFiles(inputSarifPath, checkoutPath, category, features, logger, uploadTarget) {
const pathStats = fs17.lstatSync(inputSarifPath, { throwIfNoEntry: false });
if (pathStats === void 0) {
throw new ConfigurationError(`Path does not exist: ${inputSarifPath}`);
}
const sarifPaths = getSarifFilePaths(
inputSarifPath,
uploadTarget.sarifPredicate
uploadTarget.sarifPredicate,
pathStats
);
if (sarifPaths.length === 0) {
throw new ConfigurationError(
`No SARIF files found to upload in "${inputSarifPath}".`
);
}
return uploadSpecifiedFiles(
sarifPaths,
checkoutPath,
+13 -11
View File
@@ -92374,18 +92374,10 @@ function findSarifFilesInDir(sarifPath, isSarif) {
walkSarifFiles(sarifPath);
return sarifFiles;
}
function getSarifFilePaths(sarifPath, isSarif) {
if (!fs13.existsSync(sarifPath)) {
throw new ConfigurationError(`Path does not exist: ${sarifPath}`);
}
function getSarifFilePaths(sarifPath, isSarif, pathStats) {
let sarifFiles;
if (fs13.lstatSync(sarifPath).isDirectory()) {
if (pathStats.isDirectory()) {
sarifFiles = findSarifFilesInDir(sarifPath, isSarif);
if (sarifFiles.length === 0) {
throw new ConfigurationError(
`No SARIF files found to upload in "${sarifPath}".`
);
}
} else {
sarifFiles = [sarifPath];
}
@@ -92487,10 +92479,20 @@ function buildPayload(commitOid, ref, analysisKey, analysisName, zippedSarif, wo
return payloadObj;
}
async function uploadFiles(inputSarifPath, checkoutPath, category, features, logger, uploadTarget) {
const pathStats = fs13.lstatSync(inputSarifPath, { throwIfNoEntry: false });
if (pathStats === void 0) {
throw new ConfigurationError(`Path does not exist: ${inputSarifPath}`);
}
const sarifPaths = getSarifFilePaths(
inputSarifPath,
uploadTarget.sarifPredicate
uploadTarget.sarifPredicate,
pathStats
);
if (sarifPaths.length === 0) {
throw new ConfigurationError(
`No SARIF files found to upload in "${inputSarifPath}".`
);
}
return uploadSpecifiedFiles(
sarifPaths,
checkoutPath,