Merge pull request #3084 from github/mbg/fix/hasActionsWorkflows

Fix `hasActionsWorkflows` throwing an exception if the workflows folder doesn't exist
This commit is contained in:
Michael B. Gale
2025-09-08 09:54:45 +01:00
committed by GitHub
3 changed files with 8 additions and 2 deletions
+1 -1
View File
@@ -87169,7 +87169,7 @@ async function getSupportedLanguageMap(codeql) {
var baseWorkflowsPath = ".github/workflows";
function hasActionsWorkflows(sourceRoot) {
const workflowsPath = path10.resolve(sourceRoot, baseWorkflowsPath);
const stats = fs9.lstatSync(workflowsPath);
const stats = fs9.lstatSync(workflowsPath, { throwIfNoEntry: false });
return stats !== void 0 && stats.isDirectory() && fs9.readdirSync(workflowsPath).length > 0;
}
async function getRawLanguagesInRepo(repository, sourceRoot, logger) {
+6
View File
@@ -1755,3 +1755,9 @@ for (const language in KnownLanguage) {
},
);
}
test("hasActionsWorkflows doesn't throw if workflows folder doesn't exist", async (t) => {
return withTmpDir(async (tmpDir) => {
t.notThrows(() => configUtils.hasActionsWorkflows(tmpDir));
});
});
+1 -1
View File
@@ -341,7 +341,7 @@ const baseWorkflowsPath = ".github/workflows";
*/
export function hasActionsWorkflows(sourceRoot: string): boolean {
const workflowsPath = path.resolve(sourceRoot, baseWorkflowsPath);
const stats = fs.lstatSync(workflowsPath);
const stats = fs.lstatSync(workflowsPath, { throwIfNoEntry: false });
return (
stats !== undefined &&
stats.isDirectory() &&