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

Commit 233db3c

Browse files
author
Jeremy Wiebe
committed
Fix up usage of lint-md regardless of how it's called
1 parent 5001cd0 commit 233db3c

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

docs/bin/lint-md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
#!/bin/bash -eu
2+
23
# Lints Markdown files using Mobify's `.remarkrc` configuration.
3-
FILE="$(readlink ${BASH_SOURCE[0]})"
4-
DIR="$(cd "$(dirname "$0")" && pwd)"
5-
REMARK_RC="$(dirname "$DIR/$FILE")/../remarkrc"
4+
BIN="${BASH_SOURCE[0]}"
5+
BIN_DIR="$(cd "$(dirname "$BIN")" && pwd)"
6+
7+
# We jump through some hoops here because we symlink the node module's
8+
# bin into the docs/bin/ directory and we want to support invoking
9+
# via the symlink and directly via `/docs/bin/lint-md`
10+
if [ -h "$BIN" ]; then
11+
# Dereference the symlink
12+
BIN="$BIN_DIR/$(readlink "$BIN")"
13+
fi
14+
BIN_DIR="$(cd "$(dirname "$BIN")" && pwd)"
615

7-
NPM_BIN=$(npm bin)
8-
REMARK_CLI="$NPM_BIN/remark"
16+
REMARK_RC="$BIN_DIR/../remarkrc"
17+
REMARK_CLI="$(npm bin)/remark"
918

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

0 commit comments

Comments
 (0)