Skip to content

Commit ec71a0f

Browse files
aduh95danielleadams
authored andcommitted
tools: check version number in YAML comments from changelogs
PR-URL: #37599 Refs: nodejs/remark-preset-lint-node#172 Reviewed-By: Darshan Sen <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 9c0ca46 commit ec71a0f

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

Diff for: .github/workflows/linters.yml

+6
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,16 @@ jobs:
5050
node-version: ${{ env.NODE_VERSION }}
5151
- name: Environment Information
5252
run: npx envinfo
53+
- name: Get release version numbers
54+
id: get-released-versions
55+
run: ./tools/node-lint-md-cli-rollup/src/list-released-versions-from-changelogs.mjs
5356
- name: Lint docs
5457
run: |
5558
echo "::add-matcher::.github/workflows/remark-lint-problem-matcher.json"
5659
NODE=$(command -v node) make lint-md
60+
env:
61+
NODE_RELEASED_VERSIONS: ${{ steps.get-released-versions.outputs.NODE_RELEASED_VERSIONS }}
62+
5763
lint-js:
5864
if: github.event.pull_request.draft == false
5965
runs-on: ubuntu-latest
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env node
2+
3+
import fs from 'node:fs';
4+
import { createInterface } from 'node:readline';
5+
6+
const dataFolder = new URL('../../../doc/changelogs/', import.meta.url);
7+
8+
const result = [];
9+
async function getVersionsFromFile(file) {
10+
const input = fs.createReadStream(file);
11+
let toc = false;
12+
for await (const line of createInterface({
13+
input,
14+
crlfDelay: Infinity,
15+
})) {
16+
if (toc === false && line === '<table>') {
17+
toc = true;
18+
} else if (toc && line[0] !== '<') {
19+
input.close();
20+
return;
21+
} else if (toc && line.startsWith('<a')) {
22+
result.push(line.slice(line.indexOf('>') + 1, -'</a><br/>'.length));
23+
}
24+
}
25+
}
26+
27+
const filesToCheck = [];
28+
29+
const dir = await fs.promises.opendir(dataFolder);
30+
for await (const dirent of dir) {
31+
if (dirent.isFile()) {
32+
filesToCheck.push(
33+
getVersionsFromFile(new URL(`./${dirent.name}`, dataFolder))
34+
);
35+
}
36+
}
37+
38+
await Promise.all(filesToCheck);
39+
40+
console.log(`::set-output name=NODE_RELEASED_VERSIONS::${result.join(',')}`);

0 commit comments

Comments
 (0)