Skip to content

Commit a256a58

Browse files
committed
Add check for empty objects in checkAll
1 parent a5bed11 commit a256a58

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

__tests__/fixtures/not_supported.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
label:
2-
- unknown: 'this-is-not-supported'
2+
- all:
3+
- unknown: 'this-is-not-supported'

dist/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,9 @@ exports.checkAny = checkAny;
467467
// equivalent to "Array.every()" but expanded for debugging and clarity
468468
function checkAll(matchConfigs, changedFiles) {
469469
core.debug(` checking "all" patterns`);
470-
if (!matchConfigs.length) {
470+
if (!matchConfigs.length ||
471+
// Make sure that all the configs have keys that we can check for
472+
!matchConfigs.some(configOption => ALLOWED_CONFIG_KEYS.includes(Object.keys(configOption)[0]))) {
471473
core.debug(` no "all" patterns to check`);
472474
return false;
473475
}

src/labeler.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,13 @@ export function checkAll(
260260
changedFiles: string[]
261261
): boolean {
262262
core.debug(` checking "all" patterns`);
263-
if (!matchConfigs.length) {
263+
if (
264+
!matchConfigs.length ||
265+
// Make sure that all the configs have keys that we can check for
266+
!matchConfigs.some(configOption =>
267+
ALLOWED_CONFIG_KEYS.includes(Object.keys(configOption)[0])
268+
)
269+
) {
264270
core.debug(` no "all" patterns to check`);
265271
return false;
266272
}

0 commit comments

Comments
 (0)