Skip to content

Commit 636e2a0

Browse files
authored
feat: add args input (#13)
1 parent 2f1cf31 commit 636e2a0

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

Diff for: .github/workflows/ci.yml

+9
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,12 @@ jobs:
3434
with:
3535
dprint-version: 0.30.3
3636
config-path: 'dprint.json'
37+
38+
- name: make poorly-formatted json file
39+
run: |
40+
echo '{"a": 1, "b": 2}' > poorly-formatted.json
41+
- name: Check formatting with excludes
42+
uses: ./
43+
with:
44+
args: --excludes poorly-formatted.json
45+

Diff for: README.md

+15
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,21 @@ To use a specific config, specify that with the `config-path` input:
5252
config-path: dprint-ci.json
5353
```
5454

55+
### Args
56+
57+
To pass additional arguments to `dprint check`, pass them to the `args` input. E.g. to only check changed files:
58+
59+
```yml
60+
- name: Get changed files
61+
id: changed-files
62+
uses: tj-actions/changed-files@v45
63+
- uses: dprint/[email protected]
64+
with:
65+
args: >-
66+
--allow-no-files
67+
${{ steps.changed-files.outputs.all_changed_files }}
68+
```
69+
5570
## Troubleshooting
5671

5772
### Windows line endings

Diff for: action.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ inputs:
1010
description: 'Specific dprint config to use (ex. dprint.json)'
1111
required: false
1212
default: ''
13+
args:
14+
description: 'Additional arguments to pass to dprint check'
15+
required: false
16+
default: ''
1317
runs:
1418
using: 'composite'
1519
steps:
@@ -21,11 +25,11 @@ runs:
2125
- name: Check formatting
2226
shell: bash
2327
if: "${{ inputs.config-path == '' }}"
24-
run: ~/.dprint/bin/dprint check
28+
run: ~/.dprint/bin/dprint check ${{ inputs.args }}
2529
- name: Check formatting with config
2630
shell: bash
2731
if: "${{ inputs.config-path != '' }}"
28-
run: ~/.dprint/bin/dprint check --config '${{ inputs.config-path }}'
32+
run: ~/.dprint/bin/dprint check --config '${{ inputs.config-path }}' ${{ inputs.args }}
2933
branding:
3034
icon: 'check-circle'
3135
color: 'gray-dark'

0 commit comments

Comments
 (0)