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

Commit 66325b0

Browse files
authored
Merge pull request #140 from mobify/fix-lint-md
Fix `lint-md` so it works no matter how/where it's invoked
2 parents 1a75306 + af4ba6e commit 66325b0

File tree

4 files changed

+27
-21
lines changed

4 files changed

+27
-21
lines changed

bin/lint-md

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/README.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
> Write great documentation! – * [_Mobify Developer Values_](https://github.com/mobify/developer-values#️-write-great-documentation)
1+
> Write great documentation! – \* [_Mobify Developer Values_](https://github.com/mobify/developer-values#️-write-great-documentation)
22
33
At Mobify, documentation is written in markdown.
44

@@ -9,8 +9,8 @@ docs.mobify.com.
99

1010
To make writing document easier, we provide:
1111

12-
* A linter for consistent markdown style.
13-
* A writing checklist for consistent process.
12+
- A linter for consistent markdown style.
13+
- A writing checklist for consistent process.
1414

1515
### Markdown Linting
1616

@@ -32,22 +32,24 @@ npm install --save-dev mobify-code-style
3232
**Before you start writing**
3333

3434
Write down the goal of your document.
35-
* Does a similar document exist? Could it be extended to meet the goal?
36-
* Does your document fit in an existing category? If so, which one?
35+
36+
- Does a similar document exist? Could it be extended to meet the goal?
37+
- Does your document fit in an existing category? If so, which one?
3738

3839
Who is your audience? What is their skill level?
3940

4041
What kind of document best meets your goal?
41-
* [Step-by-step tutorials](https://jacobian.org/writing/what-to-write/#tutorials)
42-
* [Overview or topical guide to a conceptual area](https://jacobian.org/writing/what-to-write/#topical-guides)
43-
* [Low-level, deep-dive reference material](https://jacobian.org/writing/what-to-write/#reference)
42+
43+
- [Step-by-step tutorials](https://jacobian.org/writing/what-to-write/#tutorials)
44+
- [Overview or topical guide to a conceptual area](https://jacobian.org/writing/what-to-write/#topical-guides)
45+
- [Low-level, deep-dive reference material](https://jacobian.org/writing/what-to-write/#reference)
4446

4547
**While writing**
4648

47-
* [Write like you talk](http://paulgraham.com/talk.html).
48-
* [Only use terms from the glossary](https://docs.google.com/document/d/1xbHkio-hdps-5zZG-SmmAKbR9WpXtrJJ-fprShN7NkM/edit).
49+
- [Write like you talk](http://paulgraham.com/talk.html).
50+
- [Only use terms from the glossary](https://docs.google.com/document/d/1xbHkio-hdps-5zZG-SmmAKbR9WpXtrJJ-fprShN7NkM/edit).
4951

5052
**After writing**
5153

52-
* [ ] 👍 Review
53-
* [ ] 🍻 Celeberate
54+
- [ ] 👍 Review
55+
- [ ] 🍻 Celeberate

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 "$@"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"url": "https://github.com/mobify/mobify-code-style/issues"
1313
},
1414
"bin": {
15-
"lint-md": "./bin/lint-md"
15+
"lint-md": "docs/bin/lint-md"
1616
},
1717
"homepage": "https://github.com/mobify/mobify-code-style",
1818
"scripts": {

0 commit comments

Comments
 (0)