Use undefined instead of NoMatchingFilesError

Add tests for `makePatternCheck` and `checkHashPatterns`
This commit is contained in:
Michael B. Gale
2025-11-05 17:23:22 +00:00
parent 03b2dc2a3f
commit 26804552e4
4 changed files with 135 additions and 71 deletions
+8 -18
View File
@@ -91053,12 +91053,6 @@ var os3 = __toESM(require("os"));
var import_path = require("path");
var actionsCache3 = __toESM(require_cache3());
var glob = __toESM(require_glob2());
var NoMatchingFilesError = class extends Error {
constructor(msg) {
super(msg);
this.name = "NoMatchingFilesError";
}
};
var CODEQL_DEPENDENCY_CACHE_PREFIX = "codeql-dependencies";
var CODEQL_DEPENDENCY_CACHE_VERSION = 1;
function getJavaTempDependencyDir() {
@@ -91077,7 +91071,7 @@ function getJavaDependencyDirs() {
async function makePatternCheck(patterns) {
const globber = await makeGlobber(patterns);
if ((await globber.glob()).length === 0) {
throw new NoMatchingFilesError();
return void 0;
}
return patterns;
}
@@ -91099,7 +91093,7 @@ async function getCsharpHashPatterns(codeql, features) {
"**/nuget.config"
]);
}
throw new NoMatchingFilesError();
return void 0;
}
var defaultCacheConfigs = {
java: {
@@ -91129,17 +91123,13 @@ async function makeGlobber(patterns) {
return glob.create(patterns.join("\n"));
}
async function checkHashPatterns(codeql, features, language, cacheConfig, logger) {
try {
return cacheConfig.getHashPatterns(codeql, features);
} catch (err) {
if (err instanceof NoMatchingFilesError) {
logger.info(
`Skipping download of dependency cache for ${language} as we cannot calculate a hash for the cache key.`
);
return void 0;
}
throw err;
const patterns = await cacheConfig.getHashPatterns(codeql, features);
if (patterns === void 0) {
logger.info(
`Skipping download of dependency cache for ${language} as we cannot calculate a hash for the cache key.`
);
}
return patterns;
}
async function uploadDependencyCaches(codeql, features, config, logger) {
const status = [];
+8 -18
View File
@@ -87240,12 +87240,6 @@ var os2 = __toESM(require("os"));
var import_path = require("path");
var actionsCache3 = __toESM(require_cache3());
var glob = __toESM(require_glob2());
var NoMatchingFilesError = class extends Error {
constructor(msg) {
super(msg);
this.name = "NoMatchingFilesError";
}
};
var CODEQL_DEPENDENCY_CACHE_PREFIX = "codeql-dependencies";
var CODEQL_DEPENDENCY_CACHE_VERSION = 1;
function getJavaTempDependencyDir() {
@@ -87264,7 +87258,7 @@ function getJavaDependencyDirs() {
async function makePatternCheck(patterns) {
const globber = await makeGlobber(patterns);
if ((await globber.glob()).length === 0) {
throw new NoMatchingFilesError();
return void 0;
}
return patterns;
}
@@ -87286,7 +87280,7 @@ async function getCsharpHashPatterns(codeql, features) {
"**/nuget.config"
]);
}
throw new NoMatchingFilesError();
return void 0;
}
var defaultCacheConfigs = {
java: {
@@ -87316,17 +87310,13 @@ async function makeGlobber(patterns) {
return glob.create(patterns.join("\n"));
}
async function checkHashPatterns(codeql, features, language, cacheConfig, logger) {
try {
return cacheConfig.getHashPatterns(codeql, features);
} catch (err) {
if (err instanceof NoMatchingFilesError) {
logger.info(
`Skipping download of dependency cache for ${language} as we cannot calculate a hash for the cache key.`
);
return void 0;
}
throw err;
const patterns = await cacheConfig.getHashPatterns(codeql, features);
if (patterns === void 0) {
logger.info(
`Skipping download of dependency cache for ${language} as we cannot calculate a hash for the cache key.`
);
}
return patterns;
}
async function downloadDependencyCaches(codeql, features, languages, logger) {
const status = [];