Skip to content

Commit

Permalink
Let's support loose equality checks by omitting false outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
Obi-Dann committed Sep 11, 2024
1 parent 9b91190 commit e89abbf
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/pull-request-verification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,17 @@ jobs:
run: echo "$OUTPUT"

- name: filter-test
if: steps.filter.outputs.local != 'true'
if: !steps.filter.outputs.local
run: exit 1

- name: count-test
if: steps.filter.outputs.local_count != 1
run: exit 1

- name: added-test
if: steps.filter.outputs.local_added != 1
if: ${{ !steps.filter.outputs.local_added }}
run: exit 1

- name: modified-test
if: steps.filter.outputs.local_modified != 0
if: ${{ steps.filter.outputs.local_modified }}
run: exit 1
9 changes: 7 additions & 2 deletions dist/index.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,21 @@ function exportResults(results: FilterResults, format: ExportFormat): void {
core.info('Matching files: none')
}

core.setOutput(key, value)
if (value) {
// GH converts all outputs to strings
// if we output false, it will be converted to 'false' which is truthy
// if we don't output false, it will be converted to undefined which is falsy
// let's not output false to allow loose equality checks
core.setOutput(key, value)
}

core.setOutput(`${key}_count`, files.length)

for (const status of Object.values(ChangeStatus)) {
core.setOutput(`${key}_${status.toLocaleLowerCase()}`, files.filter(x => x.status === status).length)
const matches = files.some(x => x.status === status)
if (matches) {
core.setOutput(`${key}_${status.toLocaleLowerCase()}`, true)
}
}

if (format !== 'none') {
Expand Down

0 comments on commit e89abbf

Please sign in to comment.