Skip to content

Commit 144880b

Browse files
authored
Merge pull request #3084 from github/mbg/fix/hasActionsWorkflows
Fix `hasActionsWorkflows` throwing an exception if the workflows folder doesn't exist
2 parents aeaa720 + e045f5e commit 144880b

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

lib/init-action.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/config-utils.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,3 +1755,9 @@ for (const language in KnownLanguage) {
17551755
},
17561756
);
17571757
}
1758+
1759+
test("hasActionsWorkflows doesn't throw if workflows folder doesn't exist", async (t) => {
1760+
return withTmpDir(async (tmpDir) => {
1761+
t.notThrows(() => configUtils.hasActionsWorkflows(tmpDir));
1762+
});
1763+
});

src/config-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ const baseWorkflowsPath = ".github/workflows";
341341
*/
342342
export function hasActionsWorkflows(sourceRoot: string): boolean {
343343
const workflowsPath = path.resolve(sourceRoot, baseWorkflowsPath);
344-
const stats = fs.lstatSync(workflowsPath);
344+
const stats = fs.lstatSync(workflowsPath, { throwIfNoEntry: false });
345345
return (
346346
stats !== undefined &&
347347
stats.isDirectory() &&

0 commit comments

Comments
 (0)