Skip to content

Commit

Permalink
feat: add args input (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
znd4 committed Sep 24, 2024
1 parent 2f1cf31 commit 636e2a0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,12 @@ jobs:
with:
dprint-version: 0.30.3
config-path: 'dprint.json'

- name: make poorly-formatted json file
run: |
echo '{"a": 1, "b": 2}' > poorly-formatted.json
- name: Check formatting with excludes
uses: ./
with:
args: --excludes poorly-formatted.json

15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,21 @@ To use a specific config, specify that with the `config-path` input:
config-path: dprint-ci.json
```

### Args

To pass additional arguments to `dprint check`, pass them to the `args` input. E.g. to only check changed files:

```yml
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v45
- uses: dprint/check@v2.2
with:
args: >-
--allow-no-files
${{ steps.changed-files.outputs.all_changed_files }}
```

## Troubleshooting

### Windows line endings
Expand Down
8 changes: 6 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ inputs:
description: 'Specific dprint config to use (ex. dprint.json)'
required: false
default: ''
args:
description: 'Additional arguments to pass to dprint check'
required: false
default: ''
runs:
using: 'composite'
steps:
Expand All @@ -21,11 +25,11 @@ runs:
- name: Check formatting
shell: bash
if: "${{ inputs.config-path == '' }}"
run: ~/.dprint/bin/dprint check
run: ~/.dprint/bin/dprint check ${{ inputs.args }}
- name: Check formatting with config
shell: bash
if: "${{ inputs.config-path != '' }}"
run: ~/.dprint/bin/dprint check --config '${{ inputs.config-path }}'
run: ~/.dprint/bin/dprint check --config '${{ inputs.config-path }}' ${{ inputs.args }}
branding:
icon: 'check-circle'
color: 'gray-dark'

0 comments on commit 636e2a0

Please sign in to comment.