Skip to content

Commit

Permalink
Merge pull request #7 from trussworks/mb-fix-markdown-toc
Browse files Browse the repository at this point in the history
Specify markdown-toc as a dependency  …
  • Loading branch information
monfresh authored Jan 29, 2021
2 parents 66fb11b + 504858c commit 1333208
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
- id: markdown-toc
name: Generate a Table of Contents in Markdown files
description: Generate a Table of Contents in Markdown files
entry: npx md-toc
entry: markdowntoc
language: node
types: ["file", "markdown"]
additional_dependencies: ["markdown-toc"]

- id: mdspell
name: Run spellcheck
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"name": "pre-commit-hooks",
"private": true,
"bin": {
"md-toc": "./pre-commit-markdown-toc",
"markdowntoc": "./pre-commit-markdown-toc",
"adr": "./pre-commit-gen-docs"
},
"scripts": {},
Expand Down
6 changes: 1 addition & 5 deletions pre-commit-markdown-toc
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,12 @@

set -eu -o pipefail

# Get the directory of this file inside pre-commit cache
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
MDTOC_BIN="${DIR}/../../node_modules/.bin/markdown-toc"

for filename in "$@"; do
# Using backticks in this appended comment seems to make the script
# indicated run after a 3/5 update to markdown-toc 1.2.0;
# stick with quotes for now.
regen=$'\n\n<!-- Regenerate with "pre-commit run -a markdown-toc" -->'

node "${MDTOC_BIN}" --bullets='*' --append="${regen}" -i "${filename}"
markdown-toc --bullets='*' --append="${regen}" -i "${filename}"
# yarn run --silent markdown-toc --bullets='*' --append="${regen}" -i "${filename}"
done

0 comments on commit 1333208

Please sign in to comment.