Check that stats isn't undefined before trying to call isDirectory

This commit is contained in:
Michael B. Gale
2025-08-07 11:25:01 +01:00
parent 43638b10a0
commit 0d72a5b371
3 changed files with 9 additions and 3 deletions

View File

@@ -337,7 +337,11 @@ const baseWorkflowsPath = ".github/workflows";
export function hasActionsWorkflows(sourceRoot: string): boolean {
const workflowsPath = path.resolve(sourceRoot, baseWorkflowsPath);
const stats = fs.lstatSync(workflowsPath);
return stats.isDirectory() && fs.readdirSync(workflowsPath).length > 0;
return (
stats !== undefined &&
stats.isDirectory() &&
fs.readdirSync(workflowsPath).length > 0
);
}
/**