Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Commit 80bb720

Browse files
author
Jeremy Wiebe
committed
Fix lint-md so it works in local repo and when used in npm package
1 parent a7efa65 commit 80bb720

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

docs/bin/lint-md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,23 @@
22

33
# Lints Markdown files using Mobify's `.remarkrc` configuration.
44
BIN="${BASH_SOURCE[0]}"
5-
BIN_DIR="$(cd "$(dirname "$BIN")" && pwd)"
65

76
# We jump through some hoops here because we symlink the node module's
87
# bin into the docs/bin/ directory and we want to support invoking
98
# via the symlink and directly via `/docs/bin/lint-md`
10-
if [ -h "$BIN" ]; then
9+
while [ -h "$BIN" ]; do
1110
# Dereference the symlink
12-
BIN="$BIN_DIR/$(readlink "$BIN")"
13-
fi
14-
BIN_DIR="$(cd "$(dirname "$BIN")" && pwd)"
11+
BIN="$(cd "$(dirname "$BIN")" && pwd)/$(readlink "$BIN")"
12+
done
1513

16-
REMARK_RC="$BIN_DIR/../remarkrc"
17-
REMARK_CLI="$(npm bin)/remark"
14+
DOCS_DIR="$(cd "$(dirname "$BIN")/.." && pwd)"
15+
REMARK_RC="$DOCS_DIR/remarkrc"
16+
17+
# This is tricky. `remark` is a dep of mobify-code-style
18+
# and so won't show up in `node_modules/.bin` of a project
19+
# that uses mobify-code-style. We have to move into the
20+
# the mobify-code-style /docs directory and find the npm
21+
# bin directory relative that _that_ to find remark!
22+
REMARK_CLI="$(cd "$DOCS_DIR" && npm bin)/remark"
1823

1924
$REMARK_CLI --rc-path $REMARK_RC "$@"

0 commit comments

Comments
 (0)