Skip to content

Commit 54be8b6

Browse files
committed
Add automation for markdown spec build/lint
1 parent bf7bfd9 commit 54be8b6

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@ on:
33
- push
44
jobs:
55
specs:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v4
9+
- uses: actions/setup-node@v4
10+
with:
11+
node-version: latest
12+
cache: npm
13+
- run: npm ci
14+
- run: npm run lint
15+
- run: npm run build-all
16+
17+
specs-old:
618
runs-on: ubuntu-22.04
719
steps:
820
- uses: actions/checkout@v3

build/build.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ dotenv.config();
2323

2424
const build = async (filename) => {
2525
const md = readFileSync(filename, "utf-8");
26-
const html = await remark()
26+
const file = await remark()
2727
.use(remarkPresetLintMarkdownStyleGuide)
2828
.use(remarkGfm)
2929
.use(remarkHeadingId)
@@ -164,11 +164,13 @@ const build = async (filename) => {
164164
</style>
165165
</head>
166166
<body>
167-
${html.toString()}
167+
${file.toString()}
168168
</body>
169169
</html>`);
170170

171-
console.error(reporter(html));
171+
console.error(reporter(file));
172+
173+
return file.messages.length;
172174
};
173175

174176
(async function () {
@@ -177,9 +179,14 @@ const build = async (filename) => {
177179
console.error("WARNING: No files built. Usage: 'npm run build -- filename.md'");
178180
}
179181

182+
let messageCount = 0;
180183
for (const filename of files) {
181184
console.log(`Building: ${filename} ...`);
182-
await build(filename);
185+
messageCount += await build(filename);
183186
console.log("");
184187
}
188+
189+
if (messageCount > 0) {
190+
process.exit(1);
191+
}
185192
}());

0 commit comments

Comments
 (0)