Skip to content

Commit 964b229

Browse files
committed
added the option to run pint in parallel mode in v1.23 or more
1 parent 22dd721 commit 964b229

File tree

2 files changed

+33
-15
lines changed

2 files changed

+33
-15
lines changed

action.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,15 @@ inputs:
2525
onlyDiff:
2626
description: "only format changed files that differ from the provided branch"
2727
required: false
28-
28+
29+
parallel:
30+
description: "run Pint in parallel mode (requires Pint >= 1.23)"
31+
required: false
32+
2933
pintVersion:
3034
description: "laravel/pint composer version to install a specific version."
3135
required: false
32-
36+
3337
useComposer:
3438
description: "Use Laravel Pint version from project composer lock file. Lock file must be preset to use this flag."
3539
required: false
@@ -42,6 +46,8 @@ runs:
4246
- ${{ inputs.config-path }}
4347
- ${{ inputs.preset }}
4448
- ${{ inputs.only-dirty }}
49+
- ${{ inputs.only-diff }}
50+
- ${{ inputs.parallel }}
4551
- ${{ inputs.pint-version }}
4652
- ${{ inputs.use-composer }}
4753
branding:

entrypoint.sh

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/bin/bash
22
set -e
33

4+
# Install Pint
45
pint_install_command=("composer global require laravel/pint:PINT_VERSION --no-progress --dev")
5-
66
if [[ "${INPUT_PINTVERSION}" ]]
77
then
88
pint_install_command="${pint_install_command/PINT_VERSION/${INPUT_PINTVERSION}}"
@@ -13,37 +13,49 @@ else
1313
pint_install_command="${pint_install_command/:PINT_VERSION/}"
1414
fi
1515

16-
pint_command=("pint")
16+
echo "Running Command: " "${pint_install_command[@]}"
17+
${pint_install_command[@]}
18+
PATH="/tmp/vendor/bin:${PATH}"
19+
20+
# Get version after installation
21+
pint_version=$(pint --version | grep -oE '[0-9]+\.[0-9]+(\.[0-9]+)?' | head -1)
22+
version_check=$(printf '%s\n1.23' "$pint_version" | sort -V | head -1)
1723

24+
# Build command with consistent array syntax
25+
pint_command=("pint")
1826
if [[ "${INPUT_TESTMODE}" == true ]]; then
19-
pint_command+=" --test"
27+
pint_command+=("--test")
2028
fi
2129

2230
if [[ "${INPUT_VERBOSEMODE}" == true ]]; then
23-
pint_command+=" -v"
31+
pint_command+=("-v")
2432
fi
2533

2634
if [[ "${INPUT_CONFIGPATH}" ]]; then
27-
pint_command+=" --config ${INPUT_CONFIGPATH}"
35+
pint_command+=("--config" "${INPUT_CONFIGPATH}")
2836
fi
2937

3038
if [[ "${INPUT_PRESET}" ]]; then
31-
pint_command+=" --preset ${INPUT_PRESET}"
39+
pint_command+=("--preset" "${INPUT_PRESET}")
3240
fi
3341

3442
if [[ "${INPUT_ONLYDIFF}" ]]; then
35-
pint_command+=" --diff=${INPUT_ONLYDIFF}"
43+
pint_command+=("--diff=${INPUT_ONLYDIFF}")
3644
fi
3745

3846
if [[ "${INPUT_ONLYDIRTY}" == true ]]; then
39-
pint_command+=" --dirty"
47+
pint_command+=("--dirty")
4048
fi
4149

42-
echo "Running Command: " "${pint_install_command[@]}"
43-
44-
${pint_install_command[@]}
45-
PATH="/tmp/vendor/bin:${PATH}"
50+
if [[ "${INPUT_PARALLEL}" == true ]]; then
51+
if [[ "$version_check" == "1.23" ]]; then
52+
pint_command+=("--parallel")
53+
echo "Parallel mode enabled (Pint version: $pint_version)"
54+
else
55+
echo "Warning: Parallel mode requested but Pint version $pint_version < 1.23. Skipping --parallel flag."
56+
fi
57+
fi
4658

4759
echo "Running Command: " "${pint_command[@]}"
4860

49-
${pint_command[@]}
61+
"${pint_command[@]}"

0 commit comments

Comments
 (0)