diff --git a/lib/init-action.js b/lib/init-action.js index ca94a55b5f..332835638c 100644 --- a/lib/init-action.js +++ b/lib/init-action.js @@ -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) { diff --git a/src/config-utils.test.ts b/src/config-utils.test.ts index c78ba6a33d..aa5764f3c7 100644 --- a/src/config-utils.test.ts +++ b/src/config-utils.test.ts @@ -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)); + }); +}); diff --git a/src/config-utils.ts b/src/config-utils.ts index 66e50e74d0..9129417479 100644 --- a/src/config-utils.ts +++ b/src/config-utils.ts @@ -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() &&