Skip to content

Commit

Permalink
pass args to command
Browse files Browse the repository at this point in the history
  • Loading branch information
alxgomz committed Dec 5, 2024
1 parent 1f97369 commit 4c103ce
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions .github/actions/md-toc/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ runs:
- name: Generate Table of Contents
env:
MDTOC_IARG: ${{ inputs.dry_run == 'false' && '-i' || '' }}
MDTOC_BARG: ${{ inputs.bullets != '' && format('--bullets {0}', inputs.bullets) || '' }}
run: |
markdown-toc "$MDTOC_IARG" \
--maxdepth "${{ inputs.depth }}" \
--append "${{ inputs.append }}" \
export MDTOC_ARGS="${{ env.MDTOC_IARG }} ${{ env.MDTOC_BARG }}"
markdown-toc $MDTOC_ARGS \
--maxdepth ${{ inputs.depth }} \
--append ${{ inputs.append }} \
${{ inputs.md_src }} && \
echo "Table of Contents successfully generated in ${{ inputs.md_src }}"
shell: bash
Expand Down
8 changes: 5 additions & 3 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@
- id: md-toc
name: Markdown Table of Contents
entry: >-
bash -eu -o pipefail -c
"for f in $@; do
markdown-toc -i $f;
bash -xeu -o pipefail -c
"MDTOC_ARGS=\"\";
for f in $@; do
[[ \"x$f\" = x--* ]] && MDTOC_ARGS=\"$f $MDTOC_ARGS\" && continue;
[ -f \"$f\" ] && markdown-toc $MDTOC_ARGS -i $f;
done"
language: system

0 comments on commit 4c103ce

Please sign in to comment.