Skip to content

Commit

Permalink
fix: "" in rules:exists should not be treated as truthy (#1485)
Browse files Browse the repository at this point in the history
  • Loading branch information
ANGkeith authored Jan 30, 2025
1 parent fbe2e5a commit 7c5c91d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,9 @@ ${evalStr}
static evaluateRuleExist (cwd: string, ruleExists: string[] | undefined): boolean {
if (ruleExists === undefined) return true;
for (const pattern of ruleExists) {
if (pattern == "") {
continue;
}
if (globby.sync(pattern, {dot: true, cwd}).length > 0) {
return true;
}
Expand Down
7 changes: 7 additions & 0 deletions tests/test-cases/rules-exists/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,10 @@ var-expand-test:
rules:
- exists:
- ${DIR}/recursive.file

rule-exist-empty-string:
script:
- echo "$CI_JOB_NAME Executed!"
rules:
- exists:
- ""
1 change: 1 addition & 0 deletions tests/test-cases/rules-exists/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ test("rules-exists", async () => {
expect(output).not.toContain("File Skipped!");
expect(output).not.toContain("Directory Skipped!");
expect(output).not.toContain("Directory Recursive Skipped!");
expect(output).not.toContain("rule-exist-empty-string Executed!");
});

0 comments on commit 7c5c91d

Please sign in to comment.